MRT: add text before -or- after file name?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Alonzo Mosley
Junior Member
Junior Member
Posts: 61
Joined: 2018-03-28, 20:13 UTC

MRT: add text before -or- after file name?

Post by *Alonzo Mosley »

Original Subject was: Restart Filenames
 
I need to use Multi Rename to, well, rename a bunch of files.

I feel like I knew how to do this at one point, but I keep screwing it up.

I need to ADD Text to the beginning of every file. I don't want to REPLACE anything, just add on to the beginning...
Dan: You're gonna need to get someone to fix my computer.
Kim: What's wrong with it?
Dan: It's in several pieces on my floor.
Alonzo Mosley
Junior Member
Junior Member
Posts: 61
Joined: 2018-03-28, 20:13 UTC

Re: Restart Filenames

Post by *Alonzo Mosley »

ALSO - I want to add text AFTER something as well.

I have a bunch of files numerically sequenced, I'd like to add a word AFTER the number - but keep the number.

If I search for \d it REPLACES not ADDS to...
Dan: You're gonna need to get someone to fix my computer.
Kim: What's wrong with it?
Dan: It's in several pieces on my floor.
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Re: Restart Filenames

Post by *ts4242 »

I need to ADD Text to the beginning of every file. I don't want to REPLACE anything, just add on to the beginning...
Use this mask

Code: Select all

sometext_[N]
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Restart Filenames

Post by *petermad »

I have a bunch of files numerically sequenced, I'd like to add a word AFTER the number - but keep the number.
Use this at "Rename mask: file name":

Code: Select all

[N]yourtext
and this at "Extension":

Code: Select all

[E]
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Alonzo Mosley
Junior Member
Junior Member
Posts: 61
Joined: 2018-03-28, 20:13 UTC

Re: Restart Filenames

Post by *Alonzo Mosley »

Wow I was clearly jetlagged when I titled this thread!

ts4242 - Brilliant! Turns out I lied when I said I knew how to do that and had forgotten, because I certainly didn't know that. Thank you.

Petermad - I was unclear in my need. I need to add words after the number, yes, but the number is in the middle of the file name. So I need to find the number (I thought that was "/d$" but am clearly wrong), but not REPLACE the number - just add text after it. But not disturb the other text that's already there.

(For example, let's say I have "Before 001 Texas Plant.jpg", "Before 002 Texas Plant.jpg", etc., I need to change it to "Before 001 Assembly Area - Texas Plant.jpg", "Before 002 Assembly Area - Texas Plant.jpg"...))

Thanks!
Dan: You're gonna need to get someone to fix my computer.
Kim: What's wrong with it?
Dan: It's in several pieces on my floor.
User avatar
Gral
Power Member
Power Member
Posts: 1460
Joined: 2005-01-26, 15:12 UTC

Re: Restart Filenames

Post by *Gral »

You need a subexpressions for search & replace, e.g.:

Search for:
(\d+)(.+)

Replace with:
$1 Assembly Area - $2
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Restart Filenames

Post by *petermad »

If the number of characters until the end of the number is fixed (11 in your examples, including the space), you can also use "Rename mask: file name":

Code: Select all

[N1-11]Assembly Area -[N11-]
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Alonzo Mosley
Junior Member
Junior Member
Posts: 61
Joined: 2018-03-28, 20:13 UTC

Re: Restart Filenames

Post by *Alonzo Mosley »

Yeah, it's not quite as clean as that... And they're not ALL "Assembly Area"... I'm spending more time figuring out the "algorithm" than probably just to grunt through it.

Thanks for your help, though! Very appreciated.
Dan: You're gonna need to get someone to fix my computer.
Kim: What's wrong with it?
Dan: It's in several pieces on my floor.
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

MRT: find a number and add before and after it new text

Post by *Stefan2 »

FROM:
Picture 001 Texas Plant.jpg
Picture 002 Texas Plant.jpg

TO:
Picture new-text-before number 001 after number Texas Plant.jpg
Picture new-text-before number 002 after number Texas Plant.jpg



USE in MRT
Name: [N]
Extension: [E]
Search : (\d+)
Replace: new-text-before number $1 after number
[x]RegEx



Explanation:
\d >>> match ''one digit''
+ >>> one-or-more of the expression right before, so here ''one-or-more of one digit''.
(...) >>> capture what is matched for reuse by ''$1'' in the replacement.

FAQs: Reguläre Ausdrücke Anleitung / Regular expressions Tutorial >>> viewtopic.php?p=323986#p323986





 
Post Reply