The tools in the Attachments toolset offer a flexible environment for batch processing of attachments. Use the tools when a large number of files need to be attached in a bulk operation. Additionally, the toolset includes tools that support processing individual attachments.
The following are two common scenarios for working with the attachment tools:
- The attachment tools use a lookup table to associate individual files to individual rows in an input table or feature class.
- The input table or feature class has an attribute field containing file paths or names of files.
For both scenarios, enable attachments on the input table or feature class using the Enable Attachments tool. Enabling attachments creates the necessary system tables and relationships to manage attachments.
Example 1: Add attachments using a match table
After enabling attachments on an input table or feature class, run the Generate Attachment Match Table tool to create a match table that will assist in associating the records from the input table with files on disk. Provide an Input Folder parameter value that contains the files to be attached and a Key Field parameter value. The tool iterates through each row in the input table and compares the value from that row's Key Field value to all of the files in the Input Folder value. A match is established when the base name (the file name without the file extension) for the file matches the value in the key field. The output created contains a MATCHID field (which represents the object ID field from the input table or feature class) and a FILENAME field (the file path to the matched file).
After generating the attachment match table, use the Add Attachments tool to attach the files to the records in the input dataset. The Add Attachments tool compares the values of the Input Join Field parameter value from the input table or feature class to the Match Join Field parameter value from the Match Table parameter value. If these two values are equal, the file from the Match Path Field value in the match table is added to the input table or feature class as an attachment.
Note:
While it's recommended, you do not have to use the Generate Attachment Match Table tool to create the match table. If the input dataset does not contain a usable key field, you can create a match table manually through an edit session or automatically using a custom script that suits the data. The match table must have the following fields:
- A field that contains the paths or names of attachment files on your computer.
- A field that contains values that can be used to join the match table to the input table or feature class.
Example 2: Add attachments without a separate match table
After enabling attachments, you may be able to use the input table or feature class to add attachments, without a separate match table. If the input table contains a field with paths to the files you want to attach, you can use it exclusively without a separate match table. Use the Add Attachments tool, specify the same table or feature class for both the Input Dataset and Match Table parameter values, and specify the Match Path Field parameter value (the field containing file paths or names of attachment files) from the input dataset.