Help with single- and double-digit regex

A swapping-ground for Regular Expression syntax

Help with single- and double-digit regex

Postby jdk » Mon Dec 10, 2012 11:10 pm

I'm terrible with regex and was wondering if anyone could help me out with the following search.
I have several hundred image files that need to have only the last part of the file name changed. They look like:

CE3701_07_03_10_08_01.gif
CE3701_07_03_10_08_02.gif
CE3701_07_03_10_08_03.gif

They need to be:

CE3701_07_03_10_08_image1.gif
CE3701_07_03_10_08_image2.gif
CE3701_07_03_10_08_image3.gif

...getting rid of the 0 in the last number and replacing it with "image".
Part of the problem is that some of these file names go up into double-digits, like:

CE3701_07_03_10_08_11.gif
CE3701_07_03_10_08_12.gif
CE3701_07_03_10_08_13.gif

and need the "image" string inserted before the whole number without the 0 being there, like this:

CE3701_07_03_10_08_image11.gif
CE3701_07_03_10_08_image12.gif
CE3701_07_03_10_08_image13.gif

This seems like it'd be easy for someone better acquainted with regex than me. Any thoughts?
Thanks!
~jdk
jdk
 
Posts: 2
Joined: Mon Dec 10, 2012 11:03 pm

Re: Help with single- and double-digit regex

Postby jdk » Tue Dec 11, 2012 7:42 pm

I was experimenting and found (?!.*_) useful in The Regex Coach. It added my "image" string to the last occurrence of "_". I figured I could just go back a second time and swap "image0" with "image" to get rid of the double-digit issue, but fr some reason this isn't working in the Rename utility, instead taking everything out but image.gif.

I'm still plugging away atit, but if anyone has any recommendations, I'd surely appreciate it.
jdk
 
Posts: 2
Joined: Mon Dec 10, 2012 11:03 pm


Return to Regular Expressions