Renumber and skipping specific numbers

Advanced Renamer forum
#1 : 14/04-22 14:20
Kaan
Kaan
Posts: 2
Hi everyone!

I have a lot of documents with a rising number in the name. Like:
axx_01_yyyy
bxx_02_yyyy
cxx_03_yyyy
dxx_04_yyyy
exx_05_yyyy

Unfortunately now I have to add new files in between the numerical oder. Has anyone an idea, how I can renumber all my files and skip specifc numbers? For example:
Skip number 3 and 5.
axx_01_yyyy
bxx_02_yyyy

cxx_04_yyyy

dxx_06_yyyy
exx_07_yyyy

Thanks!


14/04-22 14:20
#2 : 14/04-22 15:20
David Lee
David Lee
Posts: 1125
Use a script method.
Extract the number from the middle of the string
If the number is greater than or equal to 3 then increase it by 1
If the resulting number is greater than or equal to 5 then increase it by 1 again
(repeat ad lib to skip any further numbers)

Finally rebuild the filename, zero-padding the number to 2 digits.

Copy this code into the Script Window:

match = item.name.match(/([^_]*_)([^_]*)(.*)/);
d = match[2];
if (d >= 3) d++;
if (d >= 5) d++;
return match[1] + ('0' + d).slice(-2) + match[3];



14/04-22 15:20
#3 : 14/04-22 16:23
Kaan
Kaan
Posts: 2
Thank you! Works perfect!


14/04-22 16:23