RENAME OPERATION SYNTAX
A rename operation consists mainly of an Action instruction that determines how the selected charactes are going to be modified.
By default all filename characters are selected unless one or more Selector instructions are given before the action.
Basically a rename operation is a series of instructions in the form of:
Multiple rename operations can be given to perform more complex rename operations, like this:
[Selector(s)] Action : [Selector(s)] Action ...
The colon (:) is also optional. It is used as a separator mainly to improve readability.
SRename "anyfile" LOWER : LEFT 1 UPPER : RIGHT 1 UPPER
In this example 3 rename operations are given:
"LOWER" makes the whole filename lowercase because no
selector is given with it.
Operation 2: "LEFT 1" selects the first character and "UPPER" makes it uppercase.
Operation 3: "RIGHT 1"
selects the last character and "UPPER" also makes it uppercase.
General Options can be placed before all rename operations. These general options
affect every rename operation to be performed and each of them should only
be given once.
SRename "somedir/" ALL FILES LOWER : LEFT 1 UPPER : RIGHT 1 UPPER
"ALL" and "FILES" are general options. "ALL" activates recursion and "FILES" prevents directory names from being modified.
There are also options that can be given for each rename operation. These are Action options, Selector options and Separator options.
Action options should be placed after actions and Selector and Separator options should be placed before actions.
So a rename operation with options looks like this:
[Selector(s)] [Selector options] [Separator options] Action [Action options]
Example: SRename "anyfile.suffix" SUFFIX PREFIRST NOAUTOSSEP DELETE TOCOMMENT
In this rename operation "PREFIRST" is a selector option, "NOAUTOSSEP" is a separator option, and "TOCOMMENT" is an action option.
Finally some instructions accept Secondary Arguments that
should be placed immediately after those instructions.
The order that secondary arguments are given is not important if more than one are allowed.
Example: SRename "somedir/" MATCH "Reduntant" CASESENS DELETE
Here "CASESENS" is a secondary argument of the "MATCH" selector and makes the match case sensitive.
Selectors are evaluated in a fixed order and using them in a different order than the one shown below will result in an error.
The selectors shown below that are in the same line have the same priority and only one of them can be used for each rename operation.
COMMENT (CO) / BASENAME (BN)
PREFIX (PR) / MAIN (MA) / SUFFIX (SU)
LEFT (L) /
MID (M) /
This fixed order of evaluation means that you can select for example the
suffix, then a word in suffix, then match a string in the word and then
select the leftmost character in that string, but you can't for example
select the 10 leftmost characters and then match a string in those,
because MATCH will be evaluated before LEFT.
Rename operation groups (previously referred to as "Indirect Mode")
Rename operations are executed in the order that they are given and by default each operation modifies and writes the modified characters back to the filename immediately after it has been executed. This means that if multiple rename operations are executed, the result of each rename operation may depend on the result of the previous operations.
This mode of operation though straightforward hinders making more complex rename functions.
For example if you wanted to swap the positions of characters this wouldn't
To perform a position swap of "abc" with "xyz" you would use:
MATCH "abc" TO "xyz" :
MATCH "xyz" TO "abc"
But this wouldn't work because the first rename operation (MATCH "abc" TO "xyz") would
change every occurrence of "abc" to "xyz" and the second rename operation would change every "xyz" created by the first operation back to "abc", so in the end we would end up only with occurrences of "abc".
The solution to this problem is to group the 2 rename operations by enclosing them in parentheses like this:
( MATCH "abc" TO "xyz" : MATCH "xyz" TO "abc" )
Note that each parenthesis must be
separated by spaces from other instructions.
When rename operations are grouped their result isn't written back immediately but only when all rename operations in the group have finished.
Any selectors that are common to all rename operations in the group can be left outside the parentheses.
SUFFIX WORD 1 MATCH "abcd" ( LEFT 1 UP : RIGHT 1 UP )
is the same as:
( SUFFIX WORD 1 MATCH "abcd" LEFT 1 UP : SUFFIX WORD 1 MATCH "abcd" RIGHT 1 UP )
Component and Renumbering actions can't
be used in rename operation groups.
The order of rename operations in a group matters only as far
as the result of one operation overwrites the result of an earlier operation.
Renumbering actions are used in a different way than 'normal' actions. They don't use selectors so each renumbering action is a rename operation in it's own, or you could say that they just set the parameters of a single renumbering operation.
Renumbering actions can't and shouldn't be organized in rename operations separated by colons (:) but should be used all at once as a single renumbering operation.
When a renumbering operation is to be performed no other rename operations are allowed, except if the BASENAME selector is used.
RENUMBER 100 PLACES 4 NUMBERPOS -1
This renumbering operation contains 3 renumbering actions:
Action 1: RENUMBER 100 (renumbers filenames starting from 100)
Action 2: PLACES 4 (sets 4 digit numbers)
Action 3: NUMBERPOS -1
(places the numbers at the end of the filename)
Another example that uses the BASENAME selector as well:
RENUMBER 100 PLACES 4 NUMBERPOS -1 BASENAME LOWER : LEFT 1 UPPER
The BASENAME selector enables the modification of the non-numeric part of the filename sequence and can be placed before or after other renumbering actions.
There are also a few options that are used with renumbering actions and these can be placed anywhere in the command line.