MRT: Multi renaming: From 1 to 3 digits, add zeros

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Torben Abildgaard
Junior Member
Junior Member
Posts: 2
Joined: 2020-07-16, 08:20 UTC

MRT: Multi renaming: From 1 to 3 digits, add zeros

Post by *Torben Abildgaard »

My first go with Total Commander, som be easy with me.
I have more than 100 files that I have to rename for printing. Renaming file name is easy, also inserting correct date and month, but numbering troubles me.
My files are named [name][date][pagenumber]
My production today wil be named
GOFINPDT160720[pagenumer]
Pagenumbers (PDF) are 1, 2, 3, 10, 11 ...
Pagenumbers should be 001, 002, 010, 011 ...
So the final files will be names GOFINPDT160720001, GOFINPDT160720002, GOFINPDT160720003, GOFINPDT160720010, GOFINPDT160720011 ...
How do I change the pagenumber to 3 digits?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Multi renaming: From 1 digit to 3 digits

Post by *ghisler(Author) »

If the part "GOFINPDT160720" is fixed, you can use this:
GOFINPDT160720[C:3]
If the first part is different for some files but the length is fixed, you can use this:
[N1-14][C:3]
Author of Total Commander
https://www.ghisler.com
User avatar
Stefan2
Power Member
Power Member
Posts: 4132
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Multi renaming: From 1 digit to 3 digits

Post by *Stefan2 »

Hi and welcome 2Torben Abildgaard

FROM:
GOFINPDT1607203
GOFINPDT16072011
GOFINPDT160720999
TO:
GOFINPDT160720003
GOFINPDT160720011
GOFINPDT160720999

Me think its hard to do without using an external script, like VBS, PowerShell or AutoHotkey?
(because you have to capture the individual numbers and add one or two or none additional zeros)
TC can support you by providing the selected files (or all, or whole folder) as arguments to such an script.
Maybe someone has a better idea...
If you need more help, just ask.



You could maybe use regular expressions in multirenametool for each of the two possibilities (one and two page number width)
Search: ^(.+?\d\d\d\d\d\d)(\d)$
Replace: $1 00 $2

Search: ^(.+?\d\d\d\d\d\d)(\d\d)$
Replace: $1 0 $2

Or smtg like that..

 
User avatar
Stefan2
Power Member
Power Member
Posts: 4132
Joined: 2007-09-13, 22:20 UTC
Location: Europa

MRT: Multi renaming: Format 1 digit to 3 digits by adding leading zeros

Post by *Stefan2 »

OK, I tested now the RegEx,

and TC interprets the $1 + zero ("$10") as reference to the tenth sub-exepression. ($10$2)
[Up to 32 sub-expressions supported]

So add a sign between "$1" and "0" to keep or to remove afterwards, like an hashtag or an hyphen ($1#0$2) or ($1-0$2)
or escape the zero by adding an leading backslash "\" ($1\0$2)



FROM:
GOFINPDT1607203
GOFINPDT16072011
GOFINPDT160720999
TO:
GOFINPDT160720003
GOFINPDT160720011
GOFINPDT160720999

TRY:

- select all files
- start MultiRenameTool (MRT)

- Search for: ^(.+?\D\d{6})(\d)$
- [_]E [x]RegEx
- Replace with: $1\00$2
- Rename with [Start!]-button

- use the Reload button next to the [Start!]-button
- Search for: ^(.+?\D\d{6})(\d\d)$
- [_]E [x]RegEx
- Replace with: $1\0$2
- Rename with [Start!]

- OK, close


 
Torben Abildgaard
Junior Member
Junior Member
Posts: 2
Joined: 2020-07-16, 08:20 UTC

Re: Multi renaming: From 1 digit to 3 digits

Post by *Torben Abildgaard »

I am happy. Points taken
xiaomm250
Junior Member
Junior Member
Posts: 18
Joined: 2021-12-03, 09:43 UTC

Re: MRT: Multi renaming: From 1 to 3 digits, add zeros

Post by *xiaomm250 »

copy all file names to txt,
modify name by vim using regular expression,
multi rename tools by load filenames
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: MRT: Multi renaming: From 1 to 3 digits, add zeros

Post by *Usher »

xiaomm250 wrote: 2021-12-04, 04:28 UTC copy all file names to txt,
How to do it the best way?
xiaomm250 wrote: 2021-12-04, 04:28 UTC modify name by vim using regular expression,
Why do you think vim is a standard Windows editor?
What regular expression should be used?
xiaomm250 wrote: 2021-12-04, 04:28 UTC multi rename tools by load filenames
What is wrong with using regular expressions directly in MRT? It's been reported as successful.
Andrzej P. Wozniak
Polish subforum moderator
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: MRT: Multi renaming: Format 1 digit to 3 digits by adding leading zeros

Post by *hi5 »

Stefan2 wrote: 2020-07-16, 10:27 UTC - select all files
- start MultiRenameTool (MRT)
...
- use the Reload button next to the [Start!]-button
...
- OK, close
I only just saw this thread, but this I think a perfect example of why it would be so useful to allow multiple subsequent rename actions in a "macro".
Do one action :arrow: results processed by action two :arrow: results by action three etc.

In this case you would have two actions you can "play back" in one rename action.

Of course undo will be hard(er) if not impossible in some cases but that is the users risk, just slap a warning dialog in front of it :)
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
Post Reply