Hello,
I am able to export photo attachments with the generic script but I would like to name them based on a field on the record they are attached to. The field I would like to use is 'FID' and it's unique to each row in the table. The current code I use is.
import arcpy
from arcpy import da
import osinTable = arcpy.GetParameterAsText(0)
fileLocation = arcpy.GetParameterAsText(1)with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'Access Point FQN_ID']) as cursor:
for item in cursor:
attachment = item[0]
filenum = "ATT" + 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
Solved! Go to Solution.
I would use ArcCatalog to verify that the path and name of the attachment table is correct. My initial guess is that the attachment table's name is actually '...\Observations__ATTACH' (with 2 underscore characters). It appears that you are using only one underscore between Observations and ATTACH.