#1 : 12/02-20 16:52
All, I'm new to the software and in the initial stages of learning curve. I have bunch of images that I want to rename in following way -
Original name Updated name
In general naming pattern will be
G1_xxx_yy; where yy will have 2 values, "front" and "back" and xxx will start from 001 and end at 999. All images are already arranged in chronological order.
I'm not able to find a function that will allow me to do this. Any help is appreciated!
#2 : 12/02-20 18:24
Assuming the filenames are already in the correct order in the list, this script will do it:
num = Math.ceil((index + 1) / 2 );
side = (index % 2) ? '_back' : '_front';
return 'G1_' + ("00"+num).slice(-3) + side;
"index" is the position of the filename in the list - starting from zero at the top.
The function Math.ceil(x) rounds x UP to the nearest integer.
"%" is the modulo operator and returns the remainder after division, so "index % 2" will be zero if index is odd and 1 if it is even.
"?" is the conditional operator - syntax: (condition) ? value_if_true : value_if_false
12/02-20 18:24 - edited 12/02-20 18:25
#3 : 13/02-20 21:24
Reply to #2:
Thank you for the elaborate response and providing working solution! I will go through the reference you have pointed out.