Geoprocessing tools can be run in a batch mode that allows you to run the tool multiple times using many input datasets or different parameter settings. This makes it possible to run a tool many times with little interaction. For example, you can run the Clip tool in batch mode to clip several layers to the same study area.
A batch is defined as a number of iterations of a given tool. Select one of the tool's parameters to control the batch; this parameter value changes per iteration, while the remaining parameters remain constant for all iterations. In the example above, the batch has four iterations of the Clip tool. Each iteration runs the Clip tool using one of the layers in the Batch Input Features or Dataset parameter, and all other parameters remain the same across the iterations.
Configure a tool to run in batch mode
Note:
Not all geoprocessing tools support batch mode. Most notably, the following types of tools do not support batch mode:
- Tools that process multiple input datasets, such as Intersect and Merge
- Tools that create map layers, such as Make Feature Layer and Make Raster Layer
To configure a tool to run in batch mode, complete the following steps:
- Find the geoprocessing tool you want to use.
- Right-click the tool and select Batch
If the Batch command is disabled, the tool does not support batch mode.
- After selecting Batch mode, a page opens in the Geoprocessing pane where you can define various options for the batch geoprocessing tool.
- Choose the tool parameter that will drive the batch process—the batch parameter. The batch parameter is designated to accept multiple datasets or values as input. The batch tool will run once for each dataset or value you provide as input to the batch parameter. The batch parameter list only includes the tool's input parameters. The first input parameter is selected by default.
Consider the following example of a tool that has two input parameters: Input Dataset and Distance. If you select the Input Dataset parameter as the batch parameter, you can specify multiple input datasets, and the batch tool will run once for each input dataset using the same distance for each. If you select the Distance parameter as the batch parameter, you can specify multiple distances, and the batch tool will run once for each distance using the same input dataset each time.
Some input parameters are not supported as batch parameters, including all Boolean (check box) parameters, Field Map parameters, Value Table parameters, and parameters that accept multiple values.
- Specify whether the batch tool will be temporary or saved. If you save it, you can specify the new batch tool name and the toolbox where it will be saved.
The batch tool is a new model tool that is created programmatically and uses a ModelBuilder iterator to perform batch processing.
- Check or uncheck Add output datasets to an open map. To run a large batch with many iterations, uncheck this option so that a large number of layers are not added to the map.
- Click Next.
After completing the steps above, a batch version of the geoprocessing tool opens in the Geoprocessing pane, where you can specify the tool parameters and run it.
Run a tool in batch mode
The parameters displayed for the batch tool closely match the normal version of the tool. One important difference is that the parameter you selected as the batch parameter now has the Batch prefix on the parameter label and supports specifying multiple values. Each value that you provide for this batch parameter will result in an additional iteration of the tool to run within the batch.
For example, to add a field with the same name to several datasets, complete the following steps:
- Right-click the Add Field tool and select Batch.
- Select Input Table as the batch parameter and click Next.
The Batch Add Field tool opens
- For the Batch Input Table parameter, browse to and select any dataset where the new field will be added.
- Provide the new field name and type, and any other necessary parameter settings.
- Run the Batch Add Field tool.
Dynamic output naming
Most geoprocessing tools create an output dataset. When running a tool in batch mode, the naming of the tool's output datasets must receive special consideration so that a unique name is used for every iteration of the batch tool.
Batch tool outputs are dynamically named using the %Name% variable in output parameters. The %Name% variable is automatically included in every output dataset parameter. It can be manually added to other parameters that should use dynamic naming.
The %Name% variable is replaced by the value in the batch parameter during each iteration. If the value in the batch parameter contains spaces or special characters, they are replaced with an underscore. If the value is a path to a dataset, only the dataset name is used.
Note:
If you do not use the %Name% variable in the output dataset path, the same dataset path will be used for each iteration, resulting in each iteration overwriting the output of the previous iteration. This does not apply to tools that update or modify the input dataset.
For example, if a batch tool's output is set to %Name%_stats, and the Batch Input Table parameter contains tables named City, County, and State, the batch tool will create three outputs, each named after one of the inputs: City_stats, County_stats, and State_stats.
The following additional variables may be useful in dynamically specifying a parameter value. They can be used similarly to the %Name% variable.
- %Workspace Name%—The workspace or folder name of the data in the batch parameter
- %Path%—The catalog location of the data in the batch parameter, not including the data name or extension
- %Extension%—The extension of the data in the batch parameter
These variables are defined in the batch model tool using in-line variable substitution.
Add more tools to the batch
Since the batch tools you use are model tools, they can be extended with additional tools to perform a chain of processing steps. To extend a batch model, select the Save the batch tool option when creating the batch tool, so the model is saved in a location where you can find and edit it.
For example, if you started by opening the Add Field tool in batch mode, you can extend the Batch Add Field model with the Calculate Field tool so the model first adds a field to a number of datasets, and calculates the values in that field.