Page 1 of 1
Rename only last part of filenames

Posted:
Mon Nov 04, 2013 6:54 pm
by JENNINGSSSMITH
hi, I have been trying to figure out how to rename only the last portion of a filename. For example-
Current-
10506B-206-2.jpg
New-
10506B-206.jpg
I deal with many photo files that need to be edited like this. I bet there is a way, I just can't seem to figure it out.
REMOVE last part of filenames

Posted:
Tue Nov 05, 2013 7:18 am
by Stefan
How about this
FROM:
10506B-206XX.jpg
TO:
10506B-206.jpg
USE:
Remove(5)
Last n [ 2]
?
Re: Rename only last part of filenames

Posted:
Tue Nov 05, 2013 3:55 pm
by JENNINGSSSMITH
Hey, thanks for replying. You know I forgot to put in my example, What I actually need is for my file names to look something like this-
10506B-206-2.JPG
I need to change it to this-
10506B-206_1.JPG
My files have to be changed to this format in order for my web server to recognise them, but I couldn't figure out how to get just the last portion to change. I appreciate any help! Thanks
Replace last part of filename

Posted:
Tue Nov 05, 2013 5:28 pm
by truth
Heres a 1Regex solution to match filenames ending as -#
(.+)-(\d)$
\1_\2
If you also need to match filenames ending as -####
(.+)-(\d+)$
\1_\2
Re: Rename only last part of filenames

Posted:
Tue Nov 05, 2013 6:03 pm
by JENNINGSSSMITH
Hey, thanks for responding. Sorry, i'm still learning BRU. So do I need to type this in the RegEx boxes?
Match -2.JPG(.+)-(\d)$
Replace _2.jpg\1_\2
do I check the box?
or is there something else I should be doing?
Thanks for your help
Replace last part of filename

Posted:
Tue Nov 05, 2013 6:49 pm
by truth
The #1Regex Boxes (Match & Replace) should have:
(.+)-(\d)$
\1_\2
No other text should be input, the small box beside R should be checked
From there, you can select filenames to preview potential newnames
Note this example wont touch filenames ending with more than 1#
If you wish to do so, use the other Match/Replace example in previous post
Post back if you're curious as to how this matches/groups/replaces filename chars
Re: Rename only last part of filenames

Posted:
Tue Nov 05, 2013 8:39 pm
by JENNINGSSSMITH
Thanks! That worked out great!