mr, but the name was already taken) is a versy simple and intuitive file renaming tool with a very easy to learn syntax (unlike other mass renaming tools, there is only one important syntax element).
mar comes with very few command line parameters. You can list them by passing the parameter
-h to it.
$ mar -h Usage: mar [options] mask files Options: --version show program's version number and exit -h, --help show this help message and exit -n, --no-colors disable colored output -q, --quiet dismiss status informations -b, --backup creating backup CSV file -s N, --start-with=N start numbering with N instead 1 -v, --verbose print verbose output
Like all my programs,
mar uses colored output. When passing the parameter
-q all output except errors are hidden. FYI: All outputs are written to
STDERR by default because i want to extend the program in future and there will be output in
STDOUT for further processing.
In this documentation I use a set of 10 000 files. According to
mar processes (renames) all files in about 2.5 seconds – it will be fast enough for daily needs (I frequently process around 100-200 files with
mar, it happens nearly instant).
For processing files you need to pass two obligatory informations.
mask is a string containing every characters you want (please desist from using slashes. It MIGHT work for moving files, but I wouldn’t rely on it …) plus the string
%s (… and right now you’ll not be able to use a literal
%s, sorry). On file processing
%s will be replaced with the current file’s number.
files you give
mar the files you want to use. You can use anything you know from shell. Wildcards, relative paths, absolute paths, quotes, escaped characters, and so on.
The above example video shows a usual call with no parameters. You get some informations on what’s happening at the moment and after processing the files you get an information if everything went fine (“fine” as in: “the operating system did not return any errors”). If something went wrong during file processing, you get an information about this.
The above example shows all error cases. The renaming mask describes what the example is about. As you can see, the arrow’s color indicate the information type: yellow stands for informational output, red is for errors and warnings, and green is for successful operations. The last example shows a lot of informations: The ignored “not file” inputs, and two processing errors because of already existing files.
If you’re going to process important data, or want to preserve the file names for other reasons, pass the parameter
-b. This creates a (hopefully g) unique file name in the first file’s directory. This file contains a valid CSV list with old and new file names for easy processing.
"Old file name","New file name" "test/bar","test/new name 1" "test/blah","test/new name 2" "test/blubb","test/ new name 3" "test/foo","test/ new name 4" "test/moar","test/new name 5"
You can parse (with awk, for example) the file and restore the original file names, or provide the file (maybe because you renamed files for publishing them in the web and want your customers to restore actual file names).
The most simple call is
mar -qn mask files. This turns off all output except errors, and removes all ANSI color codes from error messages.
There is a package for Arch Linux in AUR. See mar-git for details. The package uses the latest Git sources accessible at GitHub.
See GitHub for details. All my code is available under GPLv3 or later.