I initially set the workspace environment to a directory and included the option, arcpy.env.overwriteOutput=True, but at some point in my script, I convert a shapefile in that directory to a geodatabase file. When I do this, I get the error:

File (filename) already exists.

I assume that because the overwriteOutput option is specified for the workspace, it doesn't apply to the geodatabase within that directory. However, I also tried to change the environment to the geodatabase and set the overwrite option to true again. The error remained.

How can I fix this (without deleting the file)?

  • Can you paste your code? And are you doing this within ArcMap, or as a standalone python script? – Dan Jurgella Apr 11 '16 at 18:01
  • In a geodatabase you can't have anything be the same name. So if you already have a point feature class called "something", then a polygon feature class cannot be called "something." Same for a table and feature class. If you are able to overwrite, it could just be you have a something in your geodatabase already called the same name but of a different type. – dslamb Apr 11 '16 at 18:16
  • I'm doing this with a standalone python script. I checked that there weren't other files with the same name. I didn't know that geodatabases couldn't contain multiple files of different types but with the same name, so thanks for letting me know. – Kris Apr 11 '16 at 18:55

Check for the file you don't want, and delete it. Something like:

arcpy.env.workspace = r"c:\temp\mydb.gdb"

if arcpy.Exists("fcToOverwrite"):

# your convert shapefile code here

See Exists - ArcGIS Desktop Help.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.