Hello all,
I'm currently working through how to export attachments from a layer on AGOL. There is only one thing I am looking for: How to make the file names match that of IDs from a field. Basically I have a list of IDs in a field called {SeasonalMeter}. I want the file names to mirror these IDs. Currently my file names are ATT###_attachment1.jpg where I'd like them to be like this for example: P70344613-H_attachment1 (P70344613-H is a value in my SeasonalMeter field column). The end goal is to bulk dump these attachment into our existing system based on these IDs.
I've used the following python code and instructions from the following:
https://support.esri.com/en/technical-article/000011912
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 = "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
I am not a programmer/ developer and do not know python. I assume that where it shows filename = filenum + str(item[1]) I would need to replace it with something to the affect -> filename = {SeasonalMeter}
I'm not familiar with coding syntax that would make this happen.
I will continue researching but I know this forum has always been a great help!
Thank you.