You are not logged in.
Pages: 1
Hello, I'm using the following regex, but in Renamer preview or analyser nothing changes:
Expression: ^(Jan|Feb|Mar|Apr|May|Jun|Jul|Apr|Sep|Oct|Nov|Dec)\s{1}(\d{2})\s{1}(\d{4})$
Replace: $3-$1-$2
Example of Expected Behavior:
Before: Coast to Coast - Apr 01 2010 - Hour 2.mp3
After: Coast to Coast - 2010-Apr-01 - Hour 2.mp3
Actually I plan to write another rule to change MMM to mm, but would like to get this working first.
Update: regexlib.com's tester confirms the expression is working as expected--detecting the date and putting the correct piece in each variable. I've used this replace metacharacter string successfully with other expressions...
Last edited by steppinwolf (2010-08-22 18:51)
Offline
Hi wolf, welcome.
Hello, I'm using the following regex, but in Renamer preview or analyser nothing changes:
Expression: ^(Jan|Feb|Mar|Apr|May|Jun|Jul|Apr|Sep|Oct|Nov|Dec)\s{1}(\d{2})\s{1}(\d{4})$
Replace: $3-$1-$2Example of Expected Behavior:
Before: Coast to Coast - Apr 01 2010 - Hour 2.mp3
After: Coast to Coast - 2010-Apr-01 - Hour 2.mp3Actually I plan to write another rule to change MMM to mm, but would like to get this working first.
Update: regexlib.com's tester confirms the expression is working as expected--detecting the date and putting the correct piece in each variable. I've used this replace metacharacter string successfully with other expressions...
You have to know that the RegEx meta sign
"^" means "Start of string" (or start of file name here) and
"$" means "End of String".
So your expression would work on an file name like "Apr 01 2010"
For an file name like "Coast to Coast - Apr 01 2010 - Hour 2.mp3" you should use
Expression: ^(.+)(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s{1}(\d{2})\s{1}(\d{4})(.+)$
Replace: $1$4-$2-$3$5
but with ReNamer you could also match an part of an string (instead of the whole string between "^" and "$") so you may just use
Expression: (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s{1}(\d{2})\s{1}(\d{4})
Replace: $3-$1-$2
All with "[X] Skip extension" enabled.
- - -
Additional note (in case you or an other don't know):
"{1}" means: one amount of the regex just before.
But an regex expression itself match every time only ONE occurrences already, so using the regex without the {1} would work too.
Expression: (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2})\s(\d{4})
Replace: $3-$1-$2
or even this will work:
Expression: (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{2}) (\d{4})
Replace: $3-$1-$2
or, if you like to know, your example file names looks like you could use:
Expression: " (\w{3}) (\d{2}) (\d{4}) "
Replace: $3-$1-$2
too.
- - -
Regarding the "MMM to mm,"
you could use an Replace Rule:
Find: Jan*|*Feb*|*Mar*|*Apr*|*May*|*Jun*|*Jul*|*Aug*|*Sep*|*Oct*|*Nov*|*Dec
Repl: 01*|*02*|*03*|*04*|*05*|*06*|*07*|*08*|*09*|*10*|*11*|*12
HTH?
Last edited by Stefan (2010-08-22 21:06)
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
Thanks Stefan, your post is like getting a regex class for free! Actually I just made a small donation through PayPal in appreciation for ReNamer and your expert assistance.
I just started playing around with regular expressions yesterday, so there's a lot I didn't know. Will give these a try.
Offline
The regex variations I tried worked perfectly as did the replace rule. No surprise to you I'm sure. Saved me a lot of time with 354 files to rename. Thanks again.
Offline
Many thanks for the feedback, great ReNamer could help you.
Thanks for the donation also in behalf of Denis.
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