I’m trying to export attachments (photos) with area_ID at the begining.
I have a feature class, a table that has _ATTACH in its name, and a relationship class. I use _ATTACH table and http://support.esri.com/technical-article/000011912 to export photos to a local folder. The name of photos look like this:
17_Photo1.jpg
18_Photo2.jpg
19_Photo3.jpg
20_Photo4.jpg
I want to get ride of 17,18,19 and 20 but add a field from the feature class at the beginning of the photos name.
How can I do that?
The field is area_ID and I want the photo names to become like this:
2AFD_Photo1.jpg
2AFD_Photo2.jpg
2AFD _Photo3.jpg
2AFD _Photo4.jpg
The script I use based on http://support.esri.com/technical-article/000011912
The script:
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 = 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
['DATA', 'ATT_NAME','ATTACHMENTID'] all these fields are in -ATTACH table and I want to add the area_ID instead of 'ATTACHMENTID' which is in the origin feature class.
Thanks