AnsweredAssumed Answered

copy_management associated_data in loop to rename only renames the first

Question asked by davper on Jan 29, 2019
Latest reply on Jan 29, 2019 by davper



I'm using the ArcGIS Pro Python console (we are using ArcGIS Desktop 10.5 mostly but its copy_management doesn't have the associated_data parameter) in order to try to do the following:


Copy all feature classes under a specific data set in an enterprise geodatabase to a new / existing data set with a specific name in the same database and in the process rename the feature classes using a suffix.


This is the current python code:

suffix = "_imahappysuffix"

in_data =  "C:/tempo/pyth/data_owner_connection.sde/db_test.dataowner.mexico"

out_data = "C:/tempo/pyth/data_owner_connection.sde/db_test.dataowner.newdataset"

arcpy.env.workspace = r'C:\tempo\pyth\data_owner_connection.sde'

dss = arcpy.ListDatasets("db_test.dataowner.mexico","Feature")

for ds in dss:
    for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
        arcpy.Copy_management(in_data, out_data, associated_data=fc+" FeatureClass "+fc+suffix)



This executes and creates a new dataset named newdataset (if it didn't exist) and then creates a copy of the first feature class with the intended suffix. The second and third feature classes in the origin data set however are only given a _1 suffix in the target data set, how come?

I think something might be wrong with how I use associated_data but I haven't figured out what yet.


In the target data set I'm getting:





Thanks for reading : )