Updated Question! I'm attempting to find/create a python script that replicates the export tool to execute batch exports of featurelayers into specific shapefiles. I want each input featurelayer to be copied and overwritten to a respective output shapefile. I want each output to have a specific name. Using either the FeatureClasstoFeatureClass_conversion() or CopyFeatures_management() functions I can get one featurelayer to output and overwrite a shapefile in a different location. But how to do this for a list of shapefiles?

import arcpy 
Mxd = arcpy.mapping.MapDocument("CURRENT")  
arcpy.env.overwriteOutput = True  

sampleinputList = ["input_a", "input_b", "input_c"] #these are feature layers in the mxd
sampleout_path = "T:/path" #path I'll be batch outputting &overwriting these shapefiles to
samplenames = ["input_a_name", "input_b_name", "input_c_name"]
sampleOutputnamesList = ["T:/path/input_a_name", "T:/path/input_b_name", "T:/path/input_c_name"] # I want each input to correspond to a respective output name
for featureclasses in sampleinputList:
#or maybe this might work?    
for featureclasses in sampleinputList:

both instances give me a Runtime error Traceback (most recent call last): File "<string>", line 2, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 2281, in CopyFeatures raise e RuntimeError: Object: Error in executing tool

  • 1
    Can you post some sample code? Would help to identify the problem. Is it possible that the file cannot be overwritten because the original shapefile is still being used in the code? – cartoscience Aug 8 '16 at 15:22
  • Hi @bleegp, I just added some code. So far I get two errors. One says the input feature does not exist or is not supported; the second says output feature class: same as input features. – StargazingFish Aug 8 '16 at 16:54
  • @StargazingFish, please edit the question to include the error messages, rather than posting them in a comment. – Tom Aug 8 '16 at 22:04
  • @Tom okay I added the specific error I'm getting. suggestions appreciated. – StargazingFish Aug 9 '16 at 17:05
  • @StargazingFish, this is completely different question now. I would recommend: reverting your edits to what you originally asked about (i.e., not being able to export to/from the same feature class); reviewing my answer and comments; accepting my answer if it got you over the original error you were encountering; and posting a new question about iterating over a list. – Tom Aug 9 '16 at 17:37

Of course you can't export to/from the same file while overwriting said file. You're trying to erase it while you're trying to read it.

You have two obvious paths:

  1. Rename the input file
  2. Export to a file with the original name (I recommend CopyFeatures for exporting)


  1. Export to an intermediate file
  2. Delete the original file
  3. Rename the intermediate file

Depending on how the data are used, it might be best to use DeleteRows and then Append, but that would required a few more steps (i.e., copying your original dataset) before you get to that point. The benefit of DeleteRows/Append is that you know that your data schema will not change.

  • Thanks @Tom. I'd like to have the input file remain with the same name mainly because it is connected to the dbf file which is updated weekly. Will deleting the original file and then renaming a new file with that old name cause that connection to be lost? That's my only concern. Can you suggest edits to my current script? – StargazingFish Aug 8 '16 at 18:06
  • 1
    @StargazingFish, it depends. How do you have them "connected"? Is it a join within the map? A relate within the map? A relationship class? Something else? It could also depend on how it is being updated. – Tom Aug 8 '16 at 19:38

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.