AnsweredAssumed Answered

Is it possible to use a field for the filename of an attachment export?

Question asked by Drrott1 on Jun 14, 2018
Latest reply on Jun 15, 2018 by Drrott1

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 os

inTable = 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

Outcomes