ArcGIS Pro provides the capability to export attachments from a feature class by saving the attached file to a file system, as described in ArcGIS Pro: Save an attachment. However, this capability is limited to saving the attachments of only one feature at a time. There is no geoprocessing tool for users to export or save attachments to all features in one process.
The instructions provided describe a method to batch export attachments from a feature class by creating a script tool.
Note: The workflow requires a Desktop Standard or Desktop Advanced license.
To batch export attachments from a feature class in ArcGIS Pro, create a script tool from a Python script that enables exporting attachments in batches from a feature class. Run the script tool by providing the parameters required.
Note: The script provided requires the standard attachment table, which is created when attachments are enabled as the input on a feature class. This is because it relies on the DATA, ATT_NAME and ATTACHMENTID fields stored in the table. A typical naming convention is to append _ATTACH to the end of the table name.
Note: The following script iterates through the entire attachment table of a single feature class and copies the attachments (saved as BLOBs or binary large objects) to a file.
import arcpy from arcpy import da import os inTable = arcpy.GetParameterAsText(0) fileLocation = arcpy.GetParameterAsText(1) with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID']) as cursor: for item in cursor: attachment = item filenum = "ATT" + str(item) + "_" filename = filenum + str(item) open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes()) del item del filenum del filename del attachment
The attachments are successfully exported in a batch, and located in the folder defined in the Output Location parameter.