You are not logged in.
Pages: 1
Hi,
Firstly, thanks for a great application. I'm using it to rename various music files as I move them all to my new NAS device.
I've a question, if I have tracks with three digit numbers at the start, how can I drop the first digit, but only for three digit numbers.
For example:
101-track1.mp3
102 - track 2.mp3
103 track 4.mp3
20 - track 20.mp3
Should become:
01-track1.mp3
02 - track 2.mp3
03 track 4.mp3
20 - track 20.mp3
So in other words:
- if a filename doesn't start with numbers, ignore it
- if it starts with two digits, ignore it
- it it starts with three digits, trim the first digit
Many thanks
Offline
Right. So I mostly struggle with RegEx, but here's my somewhat pathetic attempt anyway!
Add a RegEx rule and set:
Expression = ^(\d{1})(\d{2})(.*)$
Replace = $2$3
Copy-paste exactly, then Preview first before renaming.
It seems to work, but I'm sure our resident RegEx experts will be along soon to suggest far better ways of doing the same.
Cheers!
P.S. The Expression reads as, from L to R - "at start of string (^), if there is 1 digit (\d{1}) followed by 2 digits (\d{2}) followed by anything at all (.*) till the end of the string ($), replace with the 2nd group of characters (2 digits) followed by the 3rd group (all remaining text)".
P.P.S. RegEx is very powerful indeed, so I highly recommend you take a look at the wiki page for the same.
Last edited by Andrew (2010-04-01 10:47)
Offline
Thanks Andrew for the help, and also for the explanation which was very useful.
I can see a task for me over Easter is to try and get a bit more familiar with RegEx!!!
Offline
Expression = ^(\d{1})(\d{2})(.*)$
Replace = $2$3
Good work Andrew,
this works well, but if you don't mind let's talk about that.
1. you don't need to ()-group what you don't need as replacement, so this works too:
Expression = ^\d{1}(\d{2})(.*)$
Replace = $1$2
2. \d means already ONE digit, so you don't need {1} here:
Expression = ^\d(\d{2})(.*)$
Replace = $1$2
3. and you can shorten the RegEx even more:
Expression = ^\d(\d{2}.*)
Replace = $1
Just my two cents, but you did making the start
EDIT:
ah, i forgot: one may want to take an look at PascalScript rule and use "Serialize duplicates.pas" too
in addition, to prevent error messages on duplicate file names after preview/renameing.
EDIT 2: or
Denis> "Have a look at the Options menu (above files table), there you'll find an option called "Fix confilcting new names"."
(form http://www.den4b.com/forum/viewtopic.php?id=869)
Last edited by Stefan (2010-04-03 10:12)
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Nice Stefan, very nice indeed. Since you're one of the "resident RegEx experts" I referred to above, I knew you wouldn't fail to come to the rescue!
Offline
Since you're one of the "resident RegEx experts"
Oh?, thank you
There was no need for rescue, so it's fine that you understood the intention of my post
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Pages: 1