Batch Process

Recursively executes a command on each object that matches a specified wildcard OR on each object listed in a text file.

Usage Tips

To set your Current Workspace, use the Environment Settings dialog box (click on [Environments...] and then General Settings) before running the tool.

Command line syntax

BatchProcess <Wildcard_or_Text_File> <all feature classes | coverage | coverage feature class | dbase | file | geodatabase | geodatabase feature class | info | raster | shapefile> {all | point | label | node | line | arc | route | polygon | region} <Command_String> <run | preview>

Parameters

Expression Explanation
<Wildcard_or_Text_File>

The wild card or text file that will be used to identify which objects are to be processed.

Wildcard - the wildcard used to select the objects that are to be processed.

An asterisk (*) takes the place of zero or more characters of any kind. For example, enter 'REDRIVER_*' to select all of the objects whose name starts with the characters 'REDRIVER_'.

At least one asterisk must be included in the Wildcard, otherwise the string is assumed to be the name of a Text File.

Text File - the text file that lists the name of the objects that are to be processed.

One object name should be on each line of the file.

<all feature classes | coverage | coverage feature class | dbase | file | geodatabase | geodatabase feature class | info | raster | shapefile>

The type of object that is to be searched for matches with the Wildcard.

Object Type is only used when a Wildcard is specified. When a Text File is used, Object Type is ignored (but some value must be selected.)

The valid options are: Coverage, Coverage feature class, Dbase, File, Geodatabase, Geodatabase feature class, Info, Raster, Shapefile, and All feature classes.

The All feature classes object type includes the Coverage feature class, Geodatabase feature class, and Shapefile object types.

The Coverage object type refers to the whole coverage. One name is returned for each coverage that matches the Wildcard. Likewise the Geodatabase object type refers to the whole database.

The Coverage feature class object type refers to the feature classes within each coverage. The name of each feature class that is of the specified Feature Type, and resides within a coverage that matches the Wildcard, is returned.

For example, if the Wildcard is 'REDRIVER_BNDY*' and the Feature Type is 'ALL' and there is a coverage named REDRIVER_BNDY that contains both ARC and POLYGON feature classes, then two names will be returned for processing: REDRIVER_BNDY\ARC and REDRIVER_BNDY\POLYGON.

The Geodatabase feature class object type refers to the feature classes within each geodatabase. The name of each feature class that is of the specified Feature Type, and resides within a geodatabase that matches the Wildcard, is returned.

{all | point | label | node | line | arc | route | polygon | region}

The type of feature class that is to be searched for.

Feature Type is only used when a Wildcard is specified, and the Object Type is one of the feature class types. Otherwise Feature Type is ignored.

The valid options are: All (the default), Point, Label, Node, Line, Arc, Route, Polygon, and Region.

<Command_String>

The command string that is to be executed recursively.

Each of the objects, either that match the Wildcard/Object Type/Feature Type or that are listed in the Text File, are substituted into the Command String before each execution.

The Command String must contain at least one carrot (^). Each occurrence of a carrot in the Command String is substituted with each of the objects before execution.

For example, if the Command String is:

export cover ^ ^.e00

and the Wildcard is '*', Object Type is 'coverage', and Feature Type is 'polygon', and this returns three objects: REDRIVER_VEG, REDRIVER_GEO, and REDRIVER_BNDY, then the export command will be executed three times in succession:

  • export cover redriver_veg redriver_veg.e00
  • export cover redriver_geo redriver.e00
  • export cover redriver_bndy redriver_bndy.e00

After each execution of the command, a message is displayed in the dialog box. It will say whether the command was successful or failed.

<run | preview>

Whether to RUN the Command String recursively or to just PREVIEW what the Command String will like like after each substitution.

RUN - Run the Command String recursively. This is the default.

PREVIEW - Just display the Command String after each substitution without actually running it. It may be useful to do this to make sure you are getting what you want.

Command Line Example

Workspace c:\workspace\test.mdb
Set c:\workspace\test.mdb into workspace

BatchProcess * "geodatabase feature class" all "copyfeatures ^ c:\workspace\^s" run
Executing (BatchProcess_3): BatchProcess * "geodatabase feature class" all "copyfeatures ^ c:\docume~1\dchatfie\mydocu~1\linear~1\^s" run
Start Time: Wed May 03 14:16:39 2006
Running script BatchProcess...
copyfeatures sx_og_label c:\workspace\sx_og_labels
copyfeatures junk1 c:\workspace\junk1s
copyfeatures sx_strm_route_long c:\workspace\sx_strm_route_longs
copyfeatures sx_og_polygon c:\workspace\sx_og_polygons
copyfeatures sx_wshed_region_wshed c:\workspace\sx_wshed_region_wsheds
Completed script BatchProcess...
Executed (BatchProcess_3) successfully.
End Time: Wed May 03 14:16:52 2006 (Elapsed Time: 13.00 secs)

Scripting syntax

BatchProcess (Wildcard_or_Text_File, Object_Type, Feature_Type, Command_String, Execute_Option)

Parameters

Expression Explanation
Wildcard or Text File (Required)

The wild card or text file that will be used to identify which objects are to be processed.

Wildcard - the wildcard used to select the objects that are to be processed.

An asterisk (*) takes the place of zero or more characters of any kind. For example, enter 'REDRIVER_*' to select all of the objects whose name starts with the characters 'REDRIVER_'.

At least one asterisk must be included in the Wildcard, otherwise the string is assumed to be the name of a Text File.

Text File - the text file that lists the name of the objects that are to be processed.

One object name should be on each line of the file.

Object Type (Required)

The type of object that is to be searched for matches with the Wildcard.

Object Type is only used when a Wildcard is specified. When a Text File is used, Object Type is ignored (but some value must be selected.)

The valid options are: Coverage, Coverage feature class, Dbase, File, Geodatabase, Geodatabase feature class, Info, Raster, Shapefile, and All feature classes.

The All feature classes object type includes the Coverage feature class, Geodatabase feature class, and Shapefile object types.

The Coverage object type refers to the whole coverage. One name is returned for each coverage that matches the Wildcard. Likewise the Geodatabase object type refers to the whole database.

The Coverage feature class object type refers to the feature classes within each coverage. The name of each feature class that is of the specified Feature Type, and resides within a coverage that matches the Wildcard, is returned.

For example, if the Wildcard is 'REDRIVER_BNDY*' and the Feature Type is 'ALL' and there is a coverage named REDRIVER_BNDY that contains both ARC and POLYGON feature classes, then two names will be returned for processing: REDRIVER_BNDY\ARC and REDRIVER_BNDY\POLYGON.

The Geodatabase feature class object type refers to the feature classes within each geodatabase. The name of each feature class that is of the specified Feature Type, and resides within a geodatabase that matches the Wildcard, is returned.

Feature Type (Optional)

The type of feature class that is to be searched for.

Feature Type is only used when a Wildcard is specified, and the Object Type is one of the feature class types. Otherwise Feature Type is ignored.

The valid options are: All (the default), Point, Label, Node, Line, Arc, Route, Polygon, and Region.

Command String (Required)

The command string that is to be executed recursively.

Each of the objects, either that match the Wildcard/Object Type/Feature Type or that are listed in the Text File, are substituted into the Command String before each execution.

The Command String must contain at least one carrot (^). Each occurrence of a carrot in the Command String is substituted with each of the objects before execution.

For example, if the Command String is:

export cover ^ ^.e00

and the Wildcard is '*', Object Type is 'coverage', and Feature Type is 'polygon', and this returns three objects: REDRIVER_VEG, REDRIVER_GEO, and REDRIVER_BNDY, then the export command will be executed three times in succession:

  • export cover redriver_veg redriver_veg.e00
  • export cover redriver_geo redriver.e00
  • export cover redriver_bndy redriver_bndy.e00

After each execution of the command, a message is displayed in the dialog box. It will say whether the command was successful or failed.

Execute Option (Required)

Whether to RUN the Command String recursively or to just PREVIEW what the Command String will like like after each substitution.

RUN - Run the Command String recursively. This is the default.

PREVIEW - Just display the Command String after each substitution without actually running it. It may be useful to do this to make sure you are getting what you want.

Script Example

# Import modules.
import sys, string, os, win32com.client

# Create the Geoprocessor object
gp = win32com.client.Dispatch('esriGeoprocessing.GpDispatch.1')

# Load required toolboxes...
gp.AddToolbox('C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx')

# Load DV Linear Referencing toolbox.
gp.AddToolbox('C:/Documents and Settings/dchatfie/Application Data/ESRI/ArcToolbox/My Toolboxes/' + \
                         'DV Utilities Tools.tbx')

# Set workspace.
gp.workspace = 'c:/workspace/test.mdb'

# Convert all geodatabase feature classes beginning with 'redriver' into shapfiles.
gp.batchprocess('redriver*', 'geodatabase feature class', 'all', 'copyfeatures ^ c:\workspace\^')