Multi Rename Tool: multiple replacements at once

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Wojtek
Junior Member
Junior Member
Posts: 65
Joined: 2010-02-07, 11:58 UTC
Location: Germany

Multi Rename Tool: multiple replacements at once

Post 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.
Asus Maximus VIII Hero · Win10 Pro x64
Crucial MX500 1TB SSD · 64GB Corsair Vengeance LPX · nVidia GeForce RTX 3060 · Intel i7 7700K

Lenovo ThinkPad X1 Yoga 2.Gen · Win10 Pro x64
512GB SSD · 16GB RAM · intel HD620 · i7-7600U

TC 11.02 32-bit #347308
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48028
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Multi Rename Tool: multiple replacements at once

Post by *ghisler(Author) »

How does Notepad++ resolve the problem that | is also allowed inside a single regular expression?
Author of Total Commander
https://www.ghisler.com
User avatar
nsp
Power Member
Power Member
Posts: 1804
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Multi Rename Tool: multiple replacements at once

Post 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...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48028
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Multi Rename Tool: multiple replacements at once

Post by *ghisler(Author) »

I see, so you need to put each regular expression in braces ( ).
Author of Total Commander
https://www.ghisler.com
jjk
Member
Member
Posts: 181
Joined: 2003-07-03, 10:41 UTC

Re: Multi Rename Tool: multiple replacements at once

Post 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.
User avatar
nsp
Power Member
Power Member
Posts: 1804
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Multi Rename Tool: multiple replacements at once

Post 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-.
Jaredcat
Junior Member
Junior Member
Posts: 5
Joined: 2020-05-22, 10:21 UTC

Re: Multi Rename Tool: multiple replacements at once

Post 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.
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: Multi Rename Tool: multiple replacements at once

Post 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)
Post Reply