Page 1 of 1

Multi Rename Tool: multiple replacements at once

Posted: 2020-04-19, 22:35 UTC
by Wojtek
Hello!
I would like to be able to make multiple replacements at once.
Either by RegEx string or by TC GUI (dialog box).

The RegEx version could work like in Notepad++ S&R.
Notepad++ uses following syntax to make multiple replacements:

(String)|(String)|(String)
(?1ReplaceString)(?2ReplaceString)(?3ReplaceString)

For example:
(cat)|(dog)|(bird)
(?1Garfield)(?2Rantanplan)(?3Tweety)

will replace "cat" with "Garfield", "dog" with "Rantanplan" and "bird" with "Tweety"


The TC GUI version could work like the Plugins Search dialog (more rules or less rules)


By now there are some workarounds, but I'd rather like to have this functionality as described above.

Could you please add this feature?
I would highly appreciate it.

Re: Multi Rename Tool: multiple replacements at once

Posted: 2020-04-23, 14:46 UTC
by ghisler(Author)
How does Notepad++ resolve the problem that | is also allowed inside a single regular expression?

Re: Multi Rename Tool: multiple replacements at once

Posted: 2020-04-24, 07:23 UTC
by nsp
2ghisler
Notepad++ uses boost regular expression engine and syntax built on top of PCRE. (it could be a bit over-complicated as it is not not yet a wildly used standard.)
In replace mode you have special syntax for conditional group replacemcent see documentation. You also have a lot of feature like backtracking, named group.... wich need a lot of practice to be well used...

Re: Multi Rename Tool: multiple replacements at once

Posted: 2020-04-28, 10:56 UTC
by ghisler(Author)
I see, so you need to put each regular expression in braces ( ).

Re: Multi Rename Tool: multiple replacements at once

Posted: 2020-05-02, 20:36 UTC
by jjk
so you need to put each regular expression in braces ( )
Christian

I am also interested by that feature.
But, instead of coding at once complicated rules, you could, in first time, rather, limit expressions between braces to not regexp, just simple text. And separate each argument just by |.
And so, braces become unuseful. Only separator would be |, in search and in replace fields.

Re: Multi Rename Tool: multiple replacements at once

Posted: 2020-05-03, 10:26 UTC
by nsp
Christian

I am also interested by that feature.
But, instead of coding at once complicated rules, you could, in first time, rather, limit expressions between braces to not regexp, just simple text. And separate each argument just by |.
And so, braces become unuseful. Only separator would be |, in search and in replace fields.
[/quote]Today,
This work like this out of the box !

Code: Select all

Search For: One|Two|Three
Replace with: -1-|-2-|-3-
replace one by -1-, two by -2-, three by -3-.

Re: Multi Rename Tool: multiple replacements at once

Posted: 2020-05-22, 10:48 UTC
by Jaredcat
I agree - I use the multi rename tool for cleaning characters from downloaded mp3 filenames that cause errors in the SanDisk clip sport mp3 player. One by one I am searching for * $ & ( ) ñ ™ etc... and replacing with a blank space. I'd love to be able to do that all in one action.

Re: Multi Rename Tool: multiple replacements at once

Posted: 2020-05-22, 16:43 UTC
by gdpr deleted 6
Jaredcat wrote: 2020-05-22, 10:48 UTC I agree - I use the multi rename tool for cleaning characters from downloaded mp3 filenames that cause errors in the SanDisk clip sport mp3 player. One by one I am searching for * $ & ( ) ñ ™ etc... and replacing with a blank space. I'd love to be able to do that all in one action.
No need to do this laboriously one character by one character. This can be handled by a rather simple single regular expression. Just put all the characters you want to replace with a blank into a character class (plus a repetion quantifier if you want to avoid two or more spaces following each other); for example like:

Code: Select all

[$&()ñ™]+
Regular expressions can be quite powerful and versatile. There are many resources on the internet teaching about regular expression basics and advanced topics. Random pick: https://www.regular-expressions.info/tutorial.html

(When perusing the interwebs, be aware that different flavors/variants of regular expression exist in the world, which can differ -- sometimes just subtly -- in syntax, features and behavior. TC uses a regular expressions implementation called TRegExpr; see here for more details: https://regex.sorokin.engineer/en/latest/regular_expressions.html)