Multi-Rename Script(MRS) is open source application for massive file renaming. It is not limited to finite number of rename actions. You can rename files based on any criteria and you can write your own. Its up to you if its going to be simple file name manipulation or complex one, like using database or Internet to get information about the new file name.
MRS is influenced by Total Commander’s (TC) Multi-Rename Tool. File name masks from TC will generally work unchanged. TC content plugins are also supported and automatically recognized if you have normal TC installation. This feature alone opens the world to Explorer’s Shell Extensions which can be used as rename mask providers. Its not necessary to have Total Commander installed for any of the MRS functionality.
Additionally, MRS has its native plugin interface using AutoHotKey language. With basic programming experience you can extend file-rename operations. To create/change plugin or even MRS itself, nothing else but text editor is needed.
MRS is portable application. Just unpack the archive to the directory of your choice.
In some systems you will have to add MRS.exe in Data Execution Prevention (DEP) list. You can do so using “System” Control Panel applet (Advanced -> Performance section -> Data Execution Prevention tab).
To uninstall MRS, simply delete the directory. If you enabled shell extension you need to disable it first.
Although MRS can be used standalone, its the best to integrate it with your file manager.
Explorer
Enable Shell Extension ( ?->Settings->Enable Shell Extension ).
Total Commander
Edit Start menu ( Start->Change Start Menu ) and use following settings:
Title: Multi-Rename Script
Command: <path_to_mrs>\MRS.exe
Parameters: AutoHotKey.ini %UL
Start In: <path_to_mrs>
%UL parameter will make TC send Unicode List of files to MRS (requires TC 7.5++).
You can also recall preset directly from the TC menu to be applied as soon as you activate the menu item, without showing the MRS GUI. To do so specify MRS preset after the %UL parameter or write new preset directly. For instance, to add counter to selected files using TC file list order, use above settings with following Parameters:
Parameters: AutoHotKey.ini %UL "[C] [N]"
For other file managers procedure should be similar. See Command Line section for additional details.
Rename
In MRS, you build up a new file names using name-masks, search & replace and casing operations. File name mask is the string describing how to build up a new file name based on the currently processed file name and its position in the file list. Basic masks are always written between [ ]. Anything not among angular brackets is literal. To build up complete mask you concatenate basic masks and literal words. For instance, file name mask:
No=[C:2] Name=[N4,10]
renames files in the list so that new file names contain some literals (No= Name=), file number in the list specified with 2 digits ([C:2]) and 10 characters of original file name starting from 4th character ([N4,10]). The result for 2 files in the list is for instance:
"AFX-Lisbon Acid.mp3" ---> "No=01 Name=Lisabon Acid.mp3"
"AFX-Pitcard.Mp3" ---> "No=02 Name=Pitcard.Mp3"
There are 2 unrelated file masks, one that will be expanded to the new file name and one that will form the new file extension (File Extension Mask). You specify them in File name mask and Ext mask GUI fields. Both masks work the same way.
After the mask, file name is processed with regular expression (RE) search & replace. What you get is converted to appropriate case selected from the Case combo box.
In the file list, you can see real time preview for your current rename operation. Once you build the mask you can press Start button to rename all files in the list. You can always restore previous names with Undo operation, even if you restart the application.
Report
You can use MRS to generate file and directory reports using plugins. The difference between renaming and reporting operation is simply that you don’t use Start button but Editor Preview instead to show generated text. This means that you can use all charachters desired, not only those allowed for the file names. For example, the following mask generates CSV file with details about each file in the list containing the file/directory name, number of files in the diretory, owner, full path, and creation date:
[N];[=DirSizeCalc.File Count (on demand)] files;[=ShellDetails.Owner];[1-];[=ShellDetails.Date Created]
File name mask
File Name Mask. You can enter mask by typing, or you can expand MRS interface using expander on the middle of the GUI to select mask functions from mask categories.
Ext mask
File Extension Mask. All masks used for a file name can be used here.
Search & Replace
Enter search and replace strings here. You can specify multiple criteria by using | separator (not with RE option enabled).
For instance:
Search for: ä|ö|ü| Replace with: ae|oe|ue
If RE option is turned on search string is specified as PERL regular expression and you can use backreferences like $1 in the replace field. There are number of regular expression options that can be set at the beginning of the search string followed by an close-parenthesis. For instance, the pattern i)abc.*123 would turn on the case-insensitive option and search for “abc” followed by “123”.
Case
Specify case here to be applied finanally. To apply case on the parts of the file name, use case masks ( [U], [L] … ).
Expander
Pressing the little button on the middle of the top side of ListView control will expand user interface.
Expanded interface contains buttons that will let you select rename-mask using categories. Button Plugins will show the menu with list of installed plugins.
AHK plugins are shown bellow Total Commander plugins delimited by separator.
There is also combo box with presets you saved. Type the name and press ENTER to save the preset. Type the preset name or use the combox box to select the preset. You can delete selected preset by pressing DEL key. Pressing F12 will load default preset.
You can change/add/remove entries from the button menus by editing res\menus.ini file. The format of this file is self explanatory.
File List
This is the list of files to be renamed. Double click the file to create range mask.
You can add files using command line or drag & drop.
If you specify file name with the list of files as command line parameter, it will be used to populate the file list. The input file must contain one full file path per line.
You can also add files to the list by dropping them with the mouse. If you drop files again, you will add to the current list unless you hold the SHIFT key.
To remove selected files from the list, select them and press DELETE key.
Double click the file in the list to set the N mask range based on its name.
Start
Launch rename operation. All renamed files will be removed from the list. Files that can not be renamed due to any kind of error will stay in the list and their Error column will contan error description.
Undo
Undo the last operation. There is only 1 undo and it will not be lost if you restart MRS.
Reload
Reload the result of the pervious rename operation to the list.
Preview in editor
Show preview for all files in the list in the editor. You can use this feature to edit the result manually before doing actual renaming. To do this, save preview in the FileInfo.txt under plugins folder, and use [=FileInfo] as file-rename mask.
MRS accepts 2 command line arguments:
MRS.exe AutoHotKey.ini [fileList] [presetDef]
AutoHotKey.ini
Must be set as the first parameter.
fileList
This is list of full system paths of files you want to rename, each on new line.
presetDef
This is preset definition to be used immediately on startup.
Preset definition is string containing file mask, extension mask, search string, replace string, RE flag and case option separated by “>” symbol. For instance [N]>[E] is the same as you set file mask to [N] and extension mask to [E] and leaving all other options unchanged in GUI.
Alternatively u can use preset name by specifying “>” as the first character; for instance, you can write ">Artist - Title" on command line to rename files in the fileList using already saved preset named Artist - Title. Note that you must use quotation to specify preset name or it will be understood as command line redirection.
The same preset definition is used in MRS configuration file to store presets and last used mask, so you can also copy/paste it from there.
If presetDef is present on the command line, only progress bar will be shown and application will exit immediately after completing operation. GUI will be shown only if errors occured and it will contain list of problematic files with error descriptions.
Plugins extend the set of basic mask functions. Plugin may provide fields that can be used to specify what information to return about the file. Additionally, fields may have units to choose different format for the field data or specific information part.
To specify plugin in file mask, use [=plugin.field.unit] notation. For instance mask:
[N] [=Hash.CRC32] [=File.size.MB]MB ver[=Ver]
will append crc32, file size in megabytes and version to the original file name.
You can select range from plugin data using syntax:
[=FileInfo:4-9]
where range is used the same way as with [N] mask.
TC plugin ShellDetails provides data from Explorer’s shell extensions.
AHK plugins are single AHK script files and they have .ahk extension. To install AHK plugin, simply copy it to the plugins folder and restart the application. To disable plugin, change its extension to anything but .ahk.
About TC content plugins, MRS will try to find location of the wincmd.ini using system registry and if that fails, COMMANDER_PATH environment variable. It will then load all plugins found in TC configuration file. To override this behavior, set location of the wincmd.ini in the MRS configuration file, MRS.ini (Section: Config, Key: tcIni).
If you don’t have TC installed you can still use its content plugins. To install plugin without TC, simply copy it (or its folder) to \plugins folder. To use always plugins from the MRS plugins folder, no matter configuration of your local TC installation, set tcIni=! in MRS.ini Config section.
To verify plugin installation expand MRS interface and click Plugins button. All installed plugins should be in the list.
To Create AHK plugin nothing but the text editor is needed. Plugin interface is very simple:
#Res variable. #fn, #fe, #fp, #fd, #no contain file name, file extension, file path, file directory and file number respectively.#Res variable, again). You can use “*” here to say that plugin accepts anything as field name (this can be used to pass arbitrary parameter to the plugin). MRS will later pass the filed name to the plugin as #1 parameter to its main subroutine. To specify field unit, set units after the field name using “|” as separator.\plugins\myplugin file as a template for new plugin. You can use any AutoHotKey function when creating AHK plugin. Check out AHK documentation for details.All masks except plugin names and fields are case sensitive. White space is allowed between mask name and its parameters.
Maks are written betwen angular brackets: [mask]
| mask | description |
|---|---|
| File name | |
| N n-m | From n to m, no m means “end”, no n means “start” |
| N n,m | From n, m. |
| E n-m | Extension |
| C s+i:w | Counter S-start, i-increment, w-width |
| P | Parent dir |
| G | Grandparent dir |
| Date Time | |
| Y | Year in 4 digit form |
| y | Year in 2 digit form |
| M | Month, 2 digit |
| D | Day, 2 digit |
| t | Time, as defined in current country settings. : is replaced by a dot |
| h | Hours, always in 24 hour 2 digit format |
| m | Minutes, in 2 digit format |
| s | Seconds, in 2 digit format |
| Case | |
| U | All characters after this position in uppercase |
| L | All characters after this position in lowercase |
| F | First letter of each word uppercase after this position, all others lowercase |
| n | All characters after this position again as in original name (upper/lowercase unchanged) |
| Plugins | |
| =Plugin | 3 ways to call plugins. Range can be specified with ‘:’ using N notation: [=plugin:range] |
| =Plugin.field | |
| =Plugin.field.unit | |
| Special | |
| [ | Opening square bracket |
| ] | Closing square bracket |
MRS is free, open source application. You are encouraged to modify any part of it and share it. If you write cool plugin consider sharing it (via forum for instance) and if its of general usability I will consider including it in the future versions.
| Developed by: | Miodrag Milić |
| License: | BSD |
| Contact: | miodrag.milic@gmail.com |
| Location: | Belgrade, Serbia |
Last Changed: 09/02/2010