I'm using the following python script to export photo attachments:
from arcpy import da
import os
attachTable = arcpy.GetParameterAsText(0)
origTable = arcpy.GetParameterAsText(1)
nameField = arcpy.GetParameterAsText(2)
fileLocation = arcpy.GetParameterAsText(3)
with da.SearchCursor(attachTable,['DATA','ATT_NAME','REL_GLOBALID']) as attachCursor:
for attRow in attachCursor:
binaryRep = attRow[0]
fileName = attRow[1]
relID = attRow[2]
with da.SearchCursor(origTable,['GlobalID', nameField]) as originCursor:
for origRow in originCursor:
origID = origRow[0]
origName = origRow[1]
if origID == relID:
break
open(fileLocation + os.sep + origName + ".jpg", 'wb').write(binaryRep.tobytes())
del origRow
I get this error after running it:
Runtime error
Traceback (most recent call last): File "", line 7, in IOError: [Errno 2] No such file or directory: u'W:\work\dry_creek_exp\images\Hwy 20/Crowley Rd (turn left).jpg'
... I believe this file doesn't exist because I didn't have a photo attached to it. My question is, does anyone know of a way to get python to ignore these files that don't have attachments?? I hoping when I save this code as a script and run it on bigger projects that it will help the run time.