If you’ve ever tried to make batch edits on all or a selection of string values in an attribute table, you’ve probably spent a significant amount of time searching for the correct VBScript to plug into the Field Calculator dialogue box to get the desired results. Well search no more! A few years back I wrote the following Python scripts to simplify common batch edits made to string fields:
- Capitalize: Capitalizes the first letter of a string. Ex. Changes "hello world" to "Hello world"
- Capitalize Words: Capitalizes the first letter of every word in a string. Ex. Changes "hello world" to "Hello World"
- Lower Case to Upper Case: Converts lower case letters of a string to upper case. Ex. Changes "hello world" to "HELLO WORLD"
- LStrip: Strips a specified number of preceding characters of a string.
- LTrim: Removes preceding white spaces from the end of a string.
- Replace: Replaces current string with a new string.
- RStrip: Strips a specified number of trailing characters of a string.
- RTrim: Removes trailing white spaces from the end of a string.
- Upper Case to Lower Case: Converts upper case letters to lower case. Ex. Changes "HELLO WORLD" to "hello world"
Download the toolbox with all nine Python scripts for free! The link below retrieves a zip file containing a toolbox (.tbx), nine Python scripts (.py) listed above, and a readme.txt from the geospatial database. Right click the link and select Save Target As... Unzip the folder and be sure to store the toolbox in the same location as all of the Python scripts – relative paths are used to locate the scripts.
Batch Edit String Fields
Minimum Requirements:
ArcView license of ArcGIS 9.2
Python 2.4
The scripts can be run in either ArcMap or ArcCatalog. Edits can be made on all records in a feature layer, feature class, or shapefile. If a selection is used, the scripts will only run on the selected records. A SQL expression can be applied to the script to run on only those features that meet the conditions of the SQL expression.
*Important Note*
All changes made using these scripts are permanent unless they are used in an Edit session (ArcEditor or ArcInfo license required).
![]() |
In this example, the Capitalize Words tool converts the first letter in each word in the ADDRESS field from lower to upper case.
![]() | ![]() |



17 comments: