Generate Attachment Match Table - Python script issue

Discussion created by jamesbulmer on Nov 12, 2013
Latest reply on Nov 19, 2013 by daveb1034
Hi All,

I have a number of jpg files that I'm trying to link to records within a Feature Class, using the Attachments functionality within ArcGIS 10.1. I've done this manually with success for a few jpg files, and am now trying to automate the process.

All of the jpg files are named using the ID of the record to which they're being attached. Because there are sometimes more than one jpg per record, it is not possible to store the jps within a single folder, due to some files sharing the same name (i.e. their corresponding ID). To get around this, every jpg file is stored within an individual subfolder folder within a main folder.

The issue I'm having is when trying to use the Generate Match Table script provided within the official esri guidance here.

At the foot of this page is a code snippet that I'm following to the letter:

# Import system modules
import arcpy, os

# Set local variables.
rootFolder = 'c:/work/'

for folder in os.walk(rootFolder):
    if folder[0].find('.gdb') == -1: #exclude file geodatabases from the folder list.
        arcpy.GenerateAttachmentMatchTable_management("C:/data/parcels.gdb/parcels",folder[0],"C:/data/temp.gdb/matchtable","AttachmentKeyField", "*property*.jpg","RELATIVE")

My understanding is that this code should go through each subfolder within the main folder, pull out the required information and put this in to the Match Table. Unfortunately, this code generates an error:

ERROR 000725: Output Match Table: Dataset C:\temp\DEV\test.gdb\matchtable already exists.

It appears that this code in fact attempts to generate a Match Table PER jpg, which then crashes after the first Match Table has been created and the second Match Table cannot be created over the top of it.

It would be great to know if anyone else has experienced this issue, and/or whether a minor tweak to the python code could resolve the issue. Alternatively, does anyone have any suggestions for working around this issue - how to cycle through jpgs (some with the same names) to create the Match Table.