Generate Attachment Match Table (Data Management)


  • This tool will go through each row for the input target dataset and compare the Key Field in this dataset to the names of files in the Input Folder. For each match that occurs, a record will be created in the output table that contains the ObjectID value from the Input Dataset and the name of the matched file (or optionally the full path to that file). When used in the Add Attachments and Remove Attachments tools the MATCHID field is used as the key field to link the files on disk to records in the input dataset.

  • If the Output Match Table location is a folder, the output can be created as a dBASE table by specifying a name with the extension .dbf, or can be created as an INFO table by specifying a name with no extension. If the output location is a geodatabase, the match table will be a geodatabase table (do not specify an extension).


GenerateAttachmentMatchTable(in_dataset, in_folder, out_match_table, in_key_field, {in_file_filter}, {in_use_relative_paths})
ParameterExplanationData Type

Input dataset that contains records that will have files attached.

Table View

Folder that contains files to attach.


Table that will be generated which contains two columns: MATCHID and FILENAME.


The values in this field will match the names of the files in the input folder. The matching behavior will ignore file extensions, which allows multiple files with various file extensions to match with a single record in the input dataset.

For example, if the input Key Field value is lot5986, a file on disk named lot5986.jpg would match with this record.


This parameter is used to limit the files the tool considers for matching. If the file name does not meet the criteria in the file filter parameter it will not be processed and therefore will not show up in the output match table. Wild cards (*) can be used in this parameter for more flexible filtering options. Multiple semicolon-delimited filters can be used as well.

For example, consider a directory that contains the following files: parcel.tif, parcel.doc, parcel.jpg, houses.jpg, and report.pdf.

To limit the possible matches in this list to .jpg files, use *.jpg.

To limit the possible matches in this list to .pdf and .doc files, use *.pdf; *.doc.

To limit the possible matches in this list to files beginning with parcel, use parcel*.

To limit the possible matches in this list to files that contain the text arc, use *arc*.


Determines if the output match table field FILENAME will contain a full path to the dataset or only the file name.

  • RELATIVEThe output FILENAME field will contain relative paths. This is the default.
  • ABSOLUTEThe output FILENAME field will contain full paths to the data.

Code sample

GenerateAttachmentMatchTable example (Python window)

The following code snippet demonstrates how to use the GenerateAttachmentMatchTable in the Python window.

import arcpy
                                              "*.jpg; *.pdf",
GenerateAttachmentMatchTable example (stand-alone Python script)

The following stand-alone script demonstrates how to use the GenerateAttachmentMatchTable tool to create a match table that contains matches for only JPG and PDF files.

# Name:
# Description: Creates an attachment match table for all files that contain the string
#             'property' and are of type 'jpg' while looping through multiple folders.

# 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.


This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: Yes
  • Advanced: Yes

Related topics