Rename special with RegExp
Posted: 10 Jun 2005 15:33
Since it took me a while to figure the correct syntax for my rename job, I thought I share it with you.
I had a couple of files named:
001.jpg
002.jpg
.
.
056.jpg
and I wanted just to insert some descriptive text at the beginning of the name, but keep the numbers as they were.
Here's the RegExp solution to do the job:
(to be entered in the "Rename special" "RegExp Rename")
(^\d{3}) > My_descriptive_text_$1
Explanation:
^ = Search at the beginning of the input string
\d = Search for digits
{3} = Search for exactly 3 digits
(...) = Capture the match for reuse
$1 = Reuse the captured match
Result:
My_descriptive_text_001.jpg
My_descriptive_text_002.jpg
.
.
My_descriptive_text_056.jpg
You see, it's worth to spend some time learning RegExp syntax, maybe for more sophisticated solutions.
I had a couple of files named:
001.jpg
002.jpg
.
.
056.jpg
and I wanted just to insert some descriptive text at the beginning of the name, but keep the numbers as they were.
Here's the RegExp solution to do the job:
(to be entered in the "Rename special" "RegExp Rename")
(^\d{3}) > My_descriptive_text_$1
Explanation:
^ = Search at the beginning of the input string
\d = Search for digits
{3} = Search for exactly 3 digits
(...) = Capture the match for reuse
$1 = Reuse the captured match
Result:
My_descriptive_text_001.jpg
My_descriptive_text_002.jpg
.
.
My_descriptive_text_056.jpg
You see, it's worth to spend some time learning RegExp syntax, maybe for more sophisticated solutions.