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 fileName = attRow relID = attRow with da.SearchCursor(origTable,['GlobalID', nameField]) as originCursor: for origRow in originCursor: origID = origRow origName = origRow if origID == relID: break open(fileLocation + os.sep + origName + ".jpg", 'wb').write(binaryRep.tobytes()) del origRow
I get this error after running it:
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.