A new version of the Nomenus-rex console utility, designed for bulk file renaming, is now available. The program is written in C++ and is distributed under the GPLv3 license. Renaming rules are customizable via a configuration file. For example: source_dir = "/home/user/work/source"; destination_dir = "/home/user/work/destination"; keep_dir_structure = false; copy_or_rename = "copy"; rules = ( { type = "date"; date_format = "%Y-%m-%d"; }, { type = "text"; text = "_"; }, { type = "dir"; // mode = "whole path"|"parent dir only" mode = "whole path"; separator = "-"; }, { type = "text"; text = "_"; }, { type = "integer"; // mode = "global"|"local at every dir" mode = "local at every dir"; start = 0; step = 1; padding = 5; }, { type = "extension"; // leave the "ext" variable empty to use an original extension ext = ""; // mode = "lowercase"|"uppercase"|"sic"; mode = "lowercase"; } );
Using the specified settings, the utility will rename the file "/home/user/work/source/TestDir2/file2.txt" to "/home/user/work/destination/2022-03-16_TestDir2_0.txt". The utility also supports working with the HOME and XDG_CONFIG_HOME directories (where it looks for the configuration file in case the full path is not specified) and understands the shortcut "~" for referring to the home directory.
Changes in the new version:
- A new type of rule has been added that takes the current unfinished name as a parameter. This allowed for the introduction of a replace rule that replaces all occurrences of a substring with a new string.
- File names are now sorted alphabetically before processing. Previously, files were processed in the order provided by the file system. In the next version, this sorting will become user-controlled.
- The documentation has been revised, making it more user-friendly.
- Internal changes in the code (beginning the creation of tests and a new template function for reading enum variables from the configuration file) have been made to simplify the addition of new rules and reduce the number of new bugs.
Source: opennet.ru
