Removing Everything Before Rightmost 10 Characters and Sequencing Renamed Files

Advanced Renamer forum
#1 : 21/09-21 17:40
Jon
Jon
Posts: 2
I have a folder of images with names like the following...

red car - 123456.jpg
green truck 123456.jpg
blue boat-123456.jpg
yellow motorcycle -456789.png
black bicycle - 456789.png
white tricycle 456789.png

I first need to remove everything but 10 rightmost characters. Obviously this will fail because I would wind up with 3 images named 123456.jpg and 3 named 456789.jpg which is not allowed. To address this, I would like to add a caret "^" plus a sequence number to end up with the following...

123456^1.jpg
123456^2.jpg
123456^3.jpg
456789^1.jpg
456789^2.jpg
456789^3.jpg

I've not been able to determine how to use the Remove function to remove characters after the ten rightmost characters. I imagine that I need to use the Replace function as well but I suck at RegEx so I am humbly begging for assistance :) Any help is greatly appreciated!


21/09-21 17:40
#2 : 21/09-21 19:38
David Lee
David Lee
Posts: 1125
To remove everything except the numbers at the end you can use the Replace method...

Replace: .*?(\d*)$
with: \1
Use regular expressions
Apply to: Name

To deal with the duplicates set the Name collision rule to "Append number" and Separator = "^"

This will add sequence numbers as requested - however they will be zero-padded to 3 digits - eg 123456^001 etc

These numbers are added after all methods have been applied so you will have to run the batch and remove the leading zeroes in a separate run, using a Renumber method...

Number position: 2
Change to: Relative to existing number
Number difference: 0
Zero padding: Manual
Number length: 0


21/09-21 19:38 - edited 21/09-21 19:48
#3 : 21/09-21 19:55
David Lee
David Lee
Posts: 1125
Reply to #2:

To do EXACTLY what you were asking - ie remove everything except the last 6 characters - you could use a regex with a "lookahead"...

Remove Pattern...
Pattern: .*(?=\d{6})
Use regular expressions

Note that you are removing only 6 characters from the NAME (the 4 characters in the extension are not included).


21/09-21 19:55 - edited 21/09-21 19:56
#4 : 21/09-21 21:48
Jon
Jon
Posts: 2
Reply to #3:

Brilliant! That worked amazingly well. Thank you David. I'm always happy when I find people much smarter than myself who are willing to help :) Cheers!


21/09-21 21:48