<\/HEAD>
There are no geoprocessing tools that allow users to export and save all attachments locally. The instructions provided below describe a possible solution.<\/P>
<\/P>
The following script iterates through the entire attachment table of a single feature class and copies all attachments (stored as BLOBs or large binary objects) into a file.<\/P>
Procedure<\/H2>This script requires that the input table be the standard attachment table created when attachments are enabled on a feature class. This is because the script relies on the fields <\/SPAN>DATA<\/STRONG><\/SPAN>, <\/SPAN>ATT_NAME<\/STRONG><\/SPAN> <\/SPAN>and <\/SPAN>ATTACHMENTID<\/STRONG><\/SPAN> <\/SPAN>stored in this table. In typical naming convention,_ATTACH<\/STRONG><\/SPAN> <\/SPAN>should be appended at the end of the table name.<\/P>Copy and paste the following script into Notepad and save it as ExportAttachments.py.import arcpy
from arcpy import da
import os
import locale
import sys
reload(sys)
sys.setdefaultencoding('utf8')
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<\/BLOCKQUOTE><\/PRE><\/LI>Right-click on the toolbox and select <\/SPAN>Add > Script<\/STRONG><\/SPAN>.<\/LI>Name and label the script tool. Check the box next to <\/SPAN>Store relative path names<\/STRONG><\/SPAN> <\/SPAN>and click <\/SPAN>Next<\/STRONG><\/SPAN>.<\/LI>In the script file dialog, navigate to where ExportAttachments.py is saved. Select the script, click <\/SPAN>OK <\/SPAN><\/STRONG><\/SPAN>, and click <\/SPAN>Next<\/STRONG><\/SPAN>.<\/LI>Under <\/SPAN>Parameters<\/STRONG><\/SPAN>, type <\/SPAN>Attachment Table<\/EM> <\/SPAN>in the <\/SPAN>Display Name<\/STRONG><\/SPAN> <\/SPAN>and set its data type to <\/SPAN>Table<\/STRONG><\/SPAN>. Add a second parameter and type <\/SPAN>Output Location<\/EM> <\/SPAN>in display name and select <\/SPAN>Folder <\/Span><\/STRONG><\/SPAN>as its data type.<\/LI>Click on <\/SPAN>Finish<\/STRONG><\/SPAN>.<\/LI>A new script tool should now be added to the toolbox.<\/LI>Double-click the script tool. In the dialog box, choose the attachment table containing the attachments to be extracted for the first parameter. Choose a folder to save the exported attachments in <\/SPAN>OutputLocation<\/STRONG><\/SPAN>. Click the <\/SPAN>OK<\/STRONG><\/SPAN> <\/span>button to run the tool.<\/LI><\/>OL>