Attachments can be added manually during an editing session to a single feature with one or many files. However, adding attachments to one or more features or rows in bulk using the Add Attachments geoprocessing tool requires the creation of a match table.
A match table is also required to remove one or more attachments for one or more features using the Remove Attachments geoprocessing tool.
Match table
A match table consists of two columns and as many rows for each attachment to be added or removed from an attachment-enabled dataset. When you create a match table using the Generate Attachment Match Table geoprocessing tool, a MatchID column and a Filename column are created. The MatchID column contains object IDs from the input dataset that contain a match from file names in a designated folder location. Values in a selected key column in the attribute table are used to match file names and add them to the Filename field.
The following Generate Attachment Match Table tool parameters influence the match table results:
- Key Field—The selected field from the input dataset. The values in this field are used to match file names (not including the file extension) from the input folder.
- Input Data Filter—(Optional) A data filter limits the files considered for matching.
- Match Pattern—(Optional) The pattern used to match file names (not including the file extension) with values specified in the Key Field parameter. The match pattern type options are the following:
- Exact—File names that are an exact match to the values in the key field will be matched. This is the default.
- Prefix—File names that have the key field value at the beginning of the file name will be matched.
- Suffix—File names that have the key field value at the end of the file name will be matched.
- Any—File names that have the key field value anywhere in the file name will be matched.
- Store Relative Path—(Optional) Specifies whether the output match table file name contains full paths or only the file name.
Create a match table using an exact match pattern
To create a match table using the exact match pattern, complete the following steps:
Note:
Match tables can be created in file, mobile, or enterprise geodatabases. You must connect to the enterprise geodatabase as a user with privileges to create data in the database.
- Start ArcGIS Pro and open a project.
- On the Analysis tab in the Geoprocessing group, click Tools, and search for or browse to the Generate Attachment Match Table tool in the Data Management Tools toolset.
- Click the Generate Attachment Match Table search result to open the tool.
The Generate Attachment Match Table tool dialog box appears with default settings.
- For Input Dataset, use the browse button to select a feature class or table, or click the down arrow to choose a dataset from the active map.
- For Input Folder, use the browse button to browse to the folder that contains all the files to be loaded as attachments.
Preparing file names in the folder containing the attachment files may be necessary before creating a match table and loading attachments in ArcGIS Pro. For example, the image above displays a variety of media file formats (JPG, PDF, DOCX) in the Airport_Attachment_Files folder. Each file name in this folder contains the airport code. The airport code in this example will be a key element in matching the correct files with the correct feature or row.
- For Output Match Table, provide a name for the new table.
- For Key Field, provide a field from the dataset attribute table.
The values of this field are used to match values in the file names of the input folder. Matching is based on the Match Pattern parameter setting. For example, you can choose the CODE field to match values in each row in the file names from the Input Folder value.
- Leave the Input Data Filter parameter blank.
This parameter is optional and allows you to limit the files considered for matching. For example, if *.jpg is typed in the parameter, the tool only includes matching file names with a .jpg extension to the match table.
- For Match Pattern, keep the default setting of Exact.
This only matches files with an exact match with the values in the CODE field specified as the key field.
Other options are Prefix, Suffix, and Any.
- Optionally, keep Store Relative Path checked so the table only contains the file names.
Unchecking this option stores the full path of each file.
- Click Run to create the match table.
The new table has four rows that exactly match four file names (not including the file extension) in the input folder.
Create a match table using the any match pattern
Using the default Exact setting for the Match Pattern parameter in the previous workflow is recommended when creating an attachment match table with file names that exactly match the values in the key field.
However, you can also create a match table that matches any file name in the input folder and contains the key field values for all applicable features or rows in the input dataset. To do this, change the Match Pattern parameter value to Any and provide a different name for the match table.
Using the example data in the steps above and changing the Match Pattern parameter value to Any generates a match table with all file names included and matched to their respective features with the correct object ID when you click Run. In this example, a new match table was created with a new name.
The new table has rows that matched file names (not including the file extension) with a key value in any part of the files in the input folder.
Create a match table using a prefix match pattern
Using Prefix for the Match Pattern parameter value and the same steps and data above, the tool returns values in the key field that match the value at the beginning of the file name from the input folder.
The image below shows the match table results when you set the tool to match only *.jpg files using the Input Data Filter parameter. Data filters can be applied to all match patterns.
The new table has rows that matched file names (not including the file extension) with a key value at the beginning of the files in the input folder.
Create a match table using a suffix match pattern
You can modify the steps above by changing the Match Pattern parameter value to Suffix.
In addition to creating a match table with Match Pattern set to Suffix, this example will only return .jpg and .pdf files in the new match table. The two filters are separated by a comma in the Input Data Filter parameter.
The new table has rows that matched file names (not including the file extension) with a key value at the end of the files in the input folder.
Using any of the four match tables above with the Add Attachments tool adds the file names to their respective features using the Object ID values in the MatchID field.
Match tables can be manually edited to meet the addition and removal of attachments as needed.