Batch attachment export

6440
24
08-22-2012 08:55 AM
Status: In Product Plan
Labels (1)
MarkSmith1
Occasional Contributor

There are new tools in 10.1 to do a batch attachment but there are times where it would be useful to export out all the attachments associated to selected features in a featureclass. At the moment the only way to save attachments to file is to click on each feature and use the attachment manager to save the file(s). This is very tedious and slow if you're dealing with hundreds of features or hundreds of attachments.

24 Comments
JonathanPendleton
Agreed.
BertKraan1

Agreed, strange that this idea needs so long to be implemented.

BruceHarold

Esri Support Search-Results

41763 - Batch export attachments from a feature class

You may find the link breaks - please notify the site administrator if so.

by Anonymous User

I batch exported a bunch of photos from my feature class using the script bruce harold references (better link here). 

However that didn't do exactly what I needed it to do, I needed the feature classes ID to be exported with images so that people without ArcGIS could access and understand them. Thus I took this route, a little cumbersome but gets the job done.

  • created a new field in the attachment table (for this example it will be PT_ID)
  • join the feature class and the attachment table based on their Global_Id
  • use field calculator to copy the values of the Feature ID to the new PT_ID field, then remov the join
  • modify the code sample (reference above), by replacing the AttachmentId field with the PT_ID
  • run script in order to extract the picture attachments based on their PT_ID

The result is a folder of jpeg's, named with the PT_ID and the Photo number

TimoWidbom

This batch export attachments from a feature class script gives an error with ArcMap 10.5.1:

Traceback (most recent call last):
File "E:\GIS\riverpoints\ExportAttachments.py", line 12, in <module>
filename = filenum + str(item[1])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 3: ordinal not in range(128)

Failed to execute (ExportAttachments).

DonPritt

This idea has been posted since 2012, is there any progress as to exporting attachments using a selected table field name and exporting to a folder?

I have multiple photos per feature and would be nice to export to a folder on my computer with an associated name,

I would probably black out from the excitement of actually accomplishing this....would be huge.

CurtisDeVault

Don, one of the easiest methods I have come up with is to rename the attachment in the attachment table using whatever convention you like. You just have to make sure that it is unique. Then using the simple script that's been linked to above, it'll export your attachments using the attachment name that you have changed. I usually join the attachment table to my feature class table and use values from that concatenated together to create my file names. 

MichaelKelly

Another script is available which downloads attachments directly from hosted Feature Layers in ArcGIS Online: Downloading Feature Layer Attachments via the ArcGIS API for Python 

It's likely I'll enhance this in the coming months to allow users use an attribute as part of the attachment output name, and also make it available as a toolbox for ArcGIS Pro.

MichelleTotman

I have used a couple of different variants of this Python script. The only issue I have had with it is that it throws an unclear error when encountering corrupted attachment files.

KoryKramer

Looks like this article was updated for ArcGIS Pro: How To: Batch export attachments from a feature class in ArcGIS Pro