MRT: multiple replacements at once with RegEx

English support forum

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

MRT: multiple replacements at once with RegEx

Post by *Wojtek »

Is it possible to replace multiple strings at once with MRT?

Example RegEx in Notepad++:

Find: (cat)|(dog)|(bird)
Replace: (?1Garfield)(?2Rantanplan)(?3Tweety)

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

Is this also possible with TC MRT?
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
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: MRT: multiple replacements at once with RegEx

Post by *Hacker »

Wojtek,
Yup, press F1 in the MRT.

Search for: cat|dog|bird
Replace with: Garfield|Rantanplan|Tweety

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Wojtek
Junior Member
Junior Member
Posts: 65
Joined: 2010-02-07, 11:58 UTC
Location: Germany

Re: MRT: multiple replacements at once with RegEx

Post by *Wojtek »

Hacker wrote: 2020-04-13, 13:30 UTCYup, press F1 in the MRT.
The Help section, I know it very well.
Hacker wrote: 2020-04-13, 13:30 UTCSearch for: cat|dog|bird
Replace with: Garfield|Rantanplan|Tweety
That works fine as "normal" replacement, but not with RegEx.

My actual question is solely about RegEx, the cat & dog thing was just a simple example. I am planning to do lot more complicated stuff.
Nevertheless, thanks for your help.
So now, is there a "multi search & replace" with Regular Expressions?
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
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: MRT: multiple replacements at once with RegEx

Post by *Hacker »

Wojtek,
is there a "multi search & replace" with Regular Expressions?
Only what is documented:
Help file wrote:Subexpressions for search+replace

Text parts in round brackets are taken as subexpressions. Up to 32 subexpressions are supported now.
Example: To swap the title and interpret in the file name of an mp3 file, when they are separated by a dash (Title - Interpret.mp3), use the following options:
Search for: (.*) - (.*)\.mp3
Replace by: $2 - $1.mp3
Here $1 means the text in the first round bracket, and $2 the text in the second round bracket.
In "Replace by", use parameters \U, \L, \F, \n to convert from this point on to uppercase, lowercase, first char in word uppercase, and back to unchanged, e.g.
Search for: (.*) - (.*)\.mp3
Replace by: \U$2 - \L$1.mp3
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Stefan2
Power Member
Power Member
Posts: 4155
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: MRT: multiple replacements at once with RegEx

Post by *Stefan2 »

Wojtek wrote: 2020-04-13, 18:16 UTC ...
So now, is there a "multi search & replace" with Regular Expressions?

No, but there is an [↷] Reload-Button.
After first renaming, press the reload button to load the files again for another step.

Also you can save and load renaming presets.

For more complicated renaming task we can integrate dedicated renaming tools into TC,
while TC can help us by launching such an tool with selected files or the wanted folder.





Myself use little portable Freeware like Siren by scarabee-software and den4b ReNamer.

 
User avatar
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: MRT: multiple replacements at once with RegEx

Post by *Hacker »

One can also export a list of files, change file names as necessary, and load the new list to rename the files to into MRT.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Post Reply