Is This Content Helpful?
We're glad to know this article was helpful.
ArcGIS Pro provides the capability to export attachments from a feature class by saving the attached file to a file system, as described in the following document: Save an attached file. However, this capability is limited to saving the attachments of only one feature at a time. There is no geoprocessing tool that allows users to export or save all attachments that are attached 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 to accomplish the task.
To batch export attachments from a feature class in ArcGIS Pro, create a script tool from a Python script that allows exporting attachments in a batch from a feature class, using the workflow provided below, and run the created script tool by providing the parameters that are required by the tool.
Note: The script used to export the attachments requires the input table to be the standard attachment table created when attachments are enabled on a feature class. This is because the script relies on the DATA, ATT_NAME and ATTACHMENTID fields stored in this table. The typical naming convention of the attachment table must 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 all 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