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

English support forum

Moderators: sheep, Hacker, Stefan2, white

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

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

Post by *Alonzo Mosley » 2018-11-09, 23:23 UTC

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: 36
Joined: 2018-03-28, 20:13 UTC

Re: Restart Filenames

Post by *Alonzo Mosley » 2018-11-09, 23:25 UTC

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: 2078
Joined: 2004-02-02, 20:08 UTC
Contact:

Re: Restart Filenames

Post by *ts4242 » 2018-11-10, 01:57 UTC

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: 8807
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Restart Filenames

Post by *petermad » 2018-11-10, 11:05 UTC

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 9.5b3 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1903) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

Alonzo Mosley
Junior Member
Junior Member
Posts: 36
Joined: 2018-03-28, 20:13 UTC

Re: Restart Filenames

Post by *Alonzo Mosley » 2018-11-10, 22:32 UTC

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: 719
Joined: 2005-01-26, 15:12 UTC

Re: Restart Filenames

Post by *Gral » 2018-11-10, 23:34 UTC

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: 8807
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Restart Filenames

Post by *petermad » 2018-11-11, 01:48 UTC

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 9.5b3 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1903) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

Alonzo Mosley
Junior Member
Junior Member
Posts: 36
Joined: 2018-03-28, 20:13 UTC

Re: Restart Filenames

Post by *Alonzo Mosley » 2018-11-13, 03:23 UTC

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: 2643
Joined: 2007-09-13, 22:20 UTC
Location: Europa

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

Post by *Stefan2 » 2018-11-13, 09:03 UTC

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 >>> https://ghisler.ch/board/viewtopic.php?p=323986#p323986





 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

Post Reply