I'm trying to write script, that looks at the feature classes in a geodatabase and depending on what the feature class ends with, it creates a new dataset in the geodatabase and copies the file into the new dataset. I have 500 feature classes all ending with a value in the range '1 - 22' therefore the script should create 22 datasets and copies all files ending with the same number into its respective dataset. However, I keep getting an ERROR 000210: Failed to execute (CopyFeatures).This is the code I have so far:
import arcpy import os arcpy.env.workspace = "C:\Users\Daimon Nurse\Desktop\DFMPROJECT\DFMPROJECT.gdb" arcpy.env.overwriteOutput=True features = arcpy.ListFeatureClasses() i = 1 while i <= 22: out_dataset_path = "C:\Users\Daimon Nurse\Desktop\DFMPROJECT\DFMPROJECT.gdb" out_name = "Zone{0}".format(i) arcpy.CreateFeatureDataset_management(out_dataset_path, out_name, sr) for feature in features: outfile = os.path.join(out_dataset_path,out_name) if feature.endswith('n{0}'.format(i)): outfile1 = os.path.join(outfile,feature) arcpy.CopyFeatures_management(feature, outfile1) i = i + 1 del i, outfile, feature, features, out_name, out_dataset_path, inlayer
outfile1 = os.path.join(outfile,feature+"_copy")