I have some feature classes with attachments in personal geodatabase . I want to copy these from personal to file geodatabase automatically using arcpy. I used the code suggested by @Aaron to copy all feautre classes and datasets to file geodatabase.It was great But i couldn't copy attachments using the code.How can i copy the attachments to file gdb using arcpy?
I have assumed following:
- For your feature-classes in mdb, "_ATTACH" suffix is used for only attachment table.
- You can further customize this code.
- This code needs to be run after all featureclasses (except attachment tables- this script will create attachment table and load relationship classes from the respective table from the mdb into gdb) are moved from mdb to gdb .
It is tested in arcmap 10.3.
mdb_folder = r'C:\Users\USER_NAME\Documents\ArcGIS\gissta' gdb_folder = r'C:\Users\USER_NAME\Documents\ArcGIS\Default.gdb' tables_paths =  tables_names =  #get all attachement tables in the mdb. for w,d,f in arcpy.da.Walk(mdb_folder): for i in f: if i.endswith("__ATTACH"): tables_names.append(i) tables_paths.append(os.path.join(w,i)) #get all featureclasses have attachment tables in the **gdb** then create those tables in gdb and load data in them. for w,d,f in arcpy.da.Walk(gdb_folder): for i in f: if i in [j.replace("__ATTACH","") for j in tables_names]: pth = os.path.join(w,i) arcpy.EnableAttachments_management(in_dataset=pth) tbl = pth+"__ATTACH" for k in tables_paths: print k if i in k: arcpy.Append_management(inputs=k, target=tbl, schema_type="TEST", field_mapping="", subtype="")