Hello. Is it possible to run a batch export attachment script that exports based on a definition query assigned to the attachment table?
I was successful in running the script below. However, it exports all photos even though a definition query was applied to the table in the .mxd.
Any help is appreciated. Thank you for your time.
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[0]
filenum = "OBJ" + str(item[2]) + "_"
filename = filenum + str(item[1])
open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())
del item
del filenum
del filename
del attachment