I need to correct trinomials

Advanced Renamer forum
#1 : 21/04-19 23:14
Hal Dace
Hal Dace
Posts: 4
Hello,

Is there a way to correct trinomials so that they always have leading zeros? Examples:

1981.001.231.jpg
1981.348.016.jpg
1981.5.10.jpg
1981.89.62.jpg
1981.9.2.jpg
986.9.3.jpg

If this was my list of files, then the first two in the list are already correct and so should not be changed. The following files all have problems. I'm not too concerned about the missing "1" in the last file because fixing that manually is not too onerous. But adding leading zeros to the numbers after the dots is quite onerous because I'm constantly having to unselect different erroneous styles to add in the zeros.

I wish there was a way to fix this automatically.

Thanks, Hal Dace


21/04-19 23:14
#2 : 21/04-19 23:23
Hal Dace
Hal Dace
Posts: 4
Reply to #1:
PS - A lot of the files have further letters and numbers after the trinomials and they need to be retained.


21/04-19 23:23
#3 : 22/04-19 00:59
David Lee
David Lee
Posts: 217
Try this script.

It uses a Regular Expression to match the three numbers into elements 1 to 3 of a string array with any further characters matched into the 4th element.

It also adds a leading "1" to the first number if it is less than 1000.

var str = item.name.match(/(\d*).(\d*).(\d*)(.*)/)
if (str[1] < 1000) str[1] = "1" + str[1];
str[2] = ("000" + str[2]).slice(-3);
str[3] = ("000" + str[3]).slice(-3);
return str[1] + "." + str[2] + "." + str[3] + str[4];


22/04-19 00:59
#4 : 26/04-19 21:01
Hal Dace
Hal Dace
Posts: 4
Reply to #3:
Thanks so much. I'll give it a try


26/04-19 21:01
#5 : 26/04-19 21:13
Hal Dace
Hal Dace
Posts: 4
Reply to #3:
Yes, it's like magic! Thank you very much. Big time saver


26/04-19 21:13