Difference between revisions of "ReNamer:Rules:Replace"
(→Beware: renamed section) |
(Added "Use '$n' as 'Backreferences'") |
||
Line 74: | Line 74: | ||
| '''foo[a-z]ar '''equals '''fooaar''', '''foobar,''' '''foocar,''' '''foodar,''' etc. | | '''foo[a-z]ar '''equals '''fooaar''', '''foobar,''' '''foocar,''' '''foodar,''' etc. | ||
|} | |} | ||
+ | |||
+ | ==== Use '$n' as 'Backreferences' ==== | ||
+ | |||
+ | Use what is found by wildcards in replacement with '$n' as 'Backreferences' | ||
+ | <BR> | ||
+ | <BR> | ||
+ | If you search with wildcards '?' or '*', you can use what is found in search, in the replacement by using '$n' variables. <BR> | ||
+ | The 'n' in '$n' represents the counter as digit, counted from the left as you have used wildcards. <BR> | ||
+ | For the first used wildcard it's '$1' in the replacement, for the second it's '$2'... <BR> | ||
+ | <BR> | ||
+ | <BR> | ||
+ | For example<BR> | ||
+ | on "ReNamer.exe",<BR> | ||
+ | Find: r?n*<BR> | ||
+ | Replace: -$1-$2-<BR> | ||
+ | [x] Interpret symbols as wild cards<BR> | ||
+ | will result in: "-e-amer-.exe"<BR> | ||
+ | <BR> | ||
+ | Explanation:<BR> | ||
+ | the '?' will find the first 'e' of "ReNamer" (as searched between 'r' and 'n'),<BR> | ||
+ | and the '*' find the rest after the 'n' till the end, resulting in 'amer'.<BR> | ||
+ | <BR> | ||
+ | <BR> | ||
+ | On "Vacation 2019.txt"<BR> | ||
+ | Find: * *<BR> | ||
+ | Replace: $2 - $1<BR> | ||
+ | [x] Interpret symbols as wild cards<BR> | ||
+ | will result in "2019 - Vacation.txt"<BR> | ||
+ | <BR> | ||
+ | Explanation:<BR> | ||
+ | the '*' will find any amount of signs and store them in $1,<BR> | ||
+ | but stops on next space, as we wanted to find a space next,<BR> | ||
+ | followed by another '*', now stored in $2.<BR> | ||
+ | <BR> | ||
+ | <BR> | ||
+ | In this simple constellation this will work fine, and the two parts are swapped<BR> | ||
+ | and a hyphen is added in between as we told so in the replacement.<BR> | ||
+ | <BR> | ||
+ | For more complex issues you may better use a full featured RegularExpression rule. | ||
+ | <BR> | ||
+ | <BR> | ||
+ | <BR> | ||
+ | <BR> | ||
+ | |||
== Beware of conflicting replacements == | == Beware of conflicting replacements == |
Revision as of 10:11, 13 March 2019
Replace Rule
This rule removes the specified string from the name and replaces it with another string. It has options to replace the first occurrence, the last occurrence, or all the occurrences. You can replace multiple strings at a time. You can create a pattern with wildcards, so that any string that matches the pattern will be removed.
The parameters are as follows:
Parameter | Details |
---|---|
Find | Enter the string to be replaced.
|
button | Inserts a separator (*|*) sequence between two delimiter entries. (You can directly type*|*
You can use this button in the Replace box also. In that case, the nthe entry in the Find box is replaced by the nths entry in the Replace box. (e.g. A -->A', B -->B' etc.) } |
Replace | Enter strings that will replace the "Find" strings.
|
Insert meta tag | Click the button to see a list of meta-tags. |
Occurrences | In case that strings occur more than once in the filename, specify which occurrences should be replaced. (Options are: first only, last only, or all) |
Skip extension | If this check box is selected, the extension will be ignored by the rule. |
Case sensitive | Will only remove a specified string from the name if the case matches exactly. |
Interpret symbols as wild cards | Treat certain symbols as Wildcards for matching simple patterns (similar to Regular Expressions). |
Wildcards
Wildcard | Represents | Example |
---|---|---|
any number of characters (including numbers, space, underscores, etc.). | abc* equals abc followed by 0 or more characters. | |
Any single character (including numbers, space, underscores, etc.) | ab?d equals abcd, ab1d, ab d, ab_d, etc. | |
Brackets enclose a set of characters, any one of which may match a single character at that position. | foo[ab]ar equals fooaar and foobar | |
(only within a pair of brackets) denotes a range of characters. | foo[a-z]ar equals fooaar, foobar, foocar, foodar, etc. |
Use '$n' as 'Backreferences'
Use what is found by wildcards in replacement with '$n' as 'Backreferences'
If you search with wildcards '?' or '*', you can use what is found in search, in the replacement by using '$n' variables.
The 'n' in '$n' represents the counter as digit, counted from the left as you have used wildcards.
For the first used wildcard it's '$1' in the replacement, for the second it's '$2'...
For example
on "ReNamer.exe",
Find: r?n*
Replace: -$1-$2-
[x] Interpret symbols as wild cards
will result in: "-e-amer-.exe"
Explanation:
the '?' will find the first 'e' of "ReNamer" (as searched between 'r' and 'n'),
and the '*' find the rest after the 'n' till the end, resulting in 'amer'.
On "Vacation 2019.txt"
Find: * *
Replace: $2 - $1
[x] Interpret symbols as wild cards
will result in "2019 - Vacation.txt"
Explanation:
the '*' will find any amount of signs and store them in $1,
but stops on next space, as we wanted to find a space next,
followed by another '*', now stored in $2.
In this simple constellation this will work fine, and the two parts are swapped
and a hyphen is added in between as we told so in the replacement.
For more complex issues you may better use a full featured RegularExpression rule.
Beware of conflicting replacements
If you enter multiple find and replace strings they will be executed as multiple Replace rules, so first string will go first and only after replacing all (or first, or last) occurrences of that string the second string in the Find box will be searched & replaced.
|
|
You may expect the new name to be BAAB.mp3, but it's not. This happens because first all A's are replaced with B's (we get BBBB.mp3) and only then all B's are replaced with A's (and the final result is AAAA.mp3).
If you need to apply character-to-character mappings you should use Translit rule.