I found this code on a youtube tutorial (https://www.youtube.com/watch?v=u26Kpe4NBqU) for batching exported attachments from arcgis online.
from arcpy import da
import os
attachTable = arcpy.GetParameterAsText(0)
origTable = arcpy.GetParameterAsText(1)
nameField = arcpy.GetParameterAsText(2)
fileLocation= arcpy.GetParameterAsText(3)
attachCursor = da.SearchCursor(attachTable,['DATA', 'ATT_NAME','REL_GLOBALID'])
for attRow in attachCursor:
binaryRep = attRow[0]
fileName = attRow[1]
relID = attRow[2]
originCursor = da.SearchCursor(origTable, ['GLOBALID', nameField])
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 originCursor
BUT when I enter the script into python, I get an error here:
attachCursor = da.SearchCursor(attachTable,['DATA','ATT_NAME','REL_GLOBALID'])
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
RuntimeError: cannot open ''*
Does anyone know why I receive this error?
I think it has something to do with the Cursor (either attach or search), but I'm stuck and can only scratch my head in confusion.
... I've also tried to enter it as a script, when I do it will run but usually never to completion. It doesn't crash but just keeps going. The one time it worked took an hour for a handful of attachments and though it says it was successful, I couldn't find the exported files. I don't have enough reputation points to add all the steps I took as a pictures so here is a link to a pdf with screenshots: