I have four input feature classes and one feature dataset which I am trying to send them to. I would like the new feature classes to have the same names as the originals. My process is as follows:

for file in working_files: 
    arcpy.conversion.FeatureClassToFeatureClass(file,sesc_fd, r"C:\Users\delenteny\Documents\ArcGIS\Projects\Dale_Workspace\Dale_Workspace.gdb\%file%") 

I receive an error when running the code as above which says

The name contains invalid characters. Failed to execute (FeatureClassToFeatureClass).

  • 2
    arcpy.conversion.FeatureClassToFeatureClass(file,sesc_fd, os.path.basename(file)) but don't forget to import os first.
    – user2856
    Commented Jan 30, 2023 at 21:07
  • 1
    Your used raw formatting, not f, so the variable was not applied
    – Vince
    Commented Jan 30, 2023 at 23:00
  • An f wouldn't matter, that wouldn't be a valid f-string anyway.
    – mikewatt
    Commented Jan 31, 2023 at 1:28
  • And the 3rd parameter is a dataset "name*, not a full path.
    – user2856
    Commented Jan 31, 2023 at 4:57

1 Answer 1


Try this:

for file in working_files:
    output_location = "C:\\Users\\delenteny\\Documents\\ArcGIS\\Projects\\Dale_Workspace\\Dale_Workspace.gdb\\" + file
    arcpy.conversion.FeatureClassToFeatureClass(file, sesc_fd, output_location) 
  • Instead of string math, use os.path.join
    – Vince
    Commented Mar 2, 2023 at 3:01
  • And the first three parameters are in_features,out_path, and out_name, so the usage is wrong.
    – Vince
    Commented Mar 2, 2023 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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