GRASS logo


g.rename.many - Renames multiple maps in the current mapset.


general, map management, rename


g.rename.many --help
g.rename.many [-sd] [raster=name] [raster_3d=name] [vector=name] [separator=character] [--help] [--verbose] [--quiet] [--ui]


Skip file format and map existence checks
By default a file format check is performed and existence of map is checked before the actual renaming. This requires going through each file two times. It might be advantageous to disable the checks for renames of large number of maps. However, when this flag is used an error occurs, some maps might be renamed while some others not.
Do the checks only (dry run)
This will only perform the file format and map existence checks but it will not do the actual rename. This is useful when writing the file with renames.
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


File with rasters to be renamed
Format of the file is one raster map per line. Old name first, new name second (separated by comma by default)
File with 3D rasters to be renamed
Format of the file is one raster map per line. Old name first, new name second (separated by comma by default)
File with vectors to be renamed
Format of the file is one vector map per line. Old name first, new name second (separated by comma by default)
Field separator
Special characters: pipe, comma, space, tab, newline
Default: comma

Table of contents


g.rename.many renames multiple maps at once using g.rename module. Old and new names are read from a text file. The file format is a simple CSV (comma separated values) format with no text delimiter (e.g. no quotes around cell content). Comma is a default cell delimiter but it can be changed to anything.

Possible use cases include:


Renaming rasters

First prepare a file with names of raster maps to be renamed. The file can be prepared in spreadsheet application (and saved as CSV with cell delimiter comma and no text delimiter) or as a text file in any (plain) text editor. In any case, the result should be a plain text file with format and content similar to the following sample:
Once the file is prepared, the module can be called:
g.rename.many raster=raster_names.csv

This example worked only with raster maps. However multiple files, one for each map type, can be used at once.

Creating a file with current names

A template for renaming can be prepared using g.list module, for example in command line (bash syntax):
g.list type=raster mapset=. sep=",
" > raster_names.csv

Note that we are using only maps in a current Mapset because these are the only ones we can rename.

With some further processing file template can be made more complete by including map names twice (bash syntax):

g.list type=raster mapset=. | sed -e "s/\(.*\)/\1,\1/g" > raster_names.csv
The sed expression used here takes whatever is on a line on input and puts it twice on one line on the output separated by comma.


g.rename, g.list


Vaclav Petras, NCSU OSGeoREL


Available at: g.rename.many source code (history)

Latest change: Wednesday Mar 30 10:17:35 2022 in commit: 25b0a9981b66c443a1c1af1d5f26182c93268b45

Main index | General index | Topics index | Keywords index | Graphical index | Full index

© 2003-2024 GRASS Development Team, GRASS GIS 8.3.3dev Reference Manual