Generate Attachment Match Table (Data Management)

License Level:BasicStandardAdvanced

Summary

ArcGIS geoprocessing tool that creates a match table to be used with the Add Attachments and Remove Attachment tools.

Learn more about working with the Attachments geoprocessing tools

Usage

Syntax

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

Input dataset that contains records that will have files attached.

Table View
in_folder

Folder that contains files to attach.

Folder
out_match_table

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

Table
in_key_field

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.

Field
in_file_filter
(Optional)

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

String
in_use_relative_paths
(Optional)

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

Code Sample

GenerateAttachmentMatchTable example (Python window)

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

import arcpy
arcpy.GenerateAttachmentMatchTable_management("C:/data/parcels.gdb/parcels",
                                              "C:/attachment_folder",
                                              "C:/data/temp.gdb/matchtable",
                                              "AttachmentKeyField",
                                              "*.jpg; *.pdf",
                                              "ABSOLUTE")
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: GenerateAttachmentMatchTable_Example.py
# 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.
        arcpy.GenerateAttachmentMatchTable_management("C:/data/parcels.gdb/parcels",
                                                      folder[0],
                                                      "C:/data/temp.gdb/matchtable",
                                                      "AttachmentKeyField",
                                                      "*property*.jpg",
                                                      "RELATIVE")

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
11/18/2013