mvre
is a command line utility to systematically rename lots of
files. It uses regular expressions to match POSIX paths and
backreferences to 'copy over' parts of the file path. For a
complete and up-to-date description of the utility's capabilities
and information on its usage, please run it with the -h
option:
./mvre.py -h
To change all file extensions from txt
to tsv
, use one of the
following command alternatives:
./mvre.py '(.*)[.]txt' '\1.tsv'
./mvre.py '(.*)[.]txt' '$1.tsv'
The \1
or $1
is a backreference to the first match group. To
do the same thing using git mv
instead of mv
, pass the
--git
option to mvre
:
./mvre.py --git '(.*)[.]txt' '\1.tsv'
./mvre.py --git '(.*)[.]txt' '$1.tsv'
You can also do this across several directories by matching and back-referencing the directory names:
./mvre.py '(.*)/(.*)[.]txt' '\1/\2.tsv'
./mvre.py '(.*)/(.*)[.]txt' '$1/$2.tsv'
There are, of course, many more use cases than these few. Use the
-h
option to get more information about how to use mvre
.
mvre
is compatible with all POSIX filesystems. This includes
all distributions of Linux and Mac OS X. mvre
is mainly
developed for, and has been tested on, Ubuntu.
Please note that this utility will NEVER be compatible with MS Windows, since Windows' path separator (the backslash) conflicts with the regex escape character.
The name of this utility, mvre
is composed of the Unix command
mv
for moving or renaming files, and re
, which stands for
'regular expressions'.
There is currently no bug tracker for mvre
. If you believe to
have found a bug, please send an email to the developer at
mvre
is distributed under the BSD License. For the full license
text, please see the file LICENSE
.