Script Help!!!
Hello,
I have photo scanned roughly 1,000 sports cards front and back.
Example of how the files look:
img001.jpg
img002.jpg
img003.jpg
img004.jpg
img005.jpg
img006.jpg
img007.jpg
img008.jpg
I would like the files to follow this naming convention:
01_A.jpg
01_B.jpg
02_A.jpg
02_B.jpg
03_A.jpg
03_B.jpg
04_A.jpg
05_B.jpg
The A represents the front of the card scanned and B is the back of the card.
It would need to be a count loop. This is card 1A and 1B etc..
In the documentation example I copied this code for the script:
var str = index % 2 ? 'B' : 'A';
I cant figure out the counter loop
As an idea it would be like
count = 0
var i = index % 2 ? (count + 1)+'B' : (count +1)+'A';
It needs to be in a loop
Any ideas would be appreciated!
-Thank you
I have photo scanned roughly 1,000 sports cards front and back.
Example of how the files look:
img001.jpg
img002.jpg
img003.jpg
img004.jpg
img005.jpg
img006.jpg
img007.jpg
img008.jpg
I would like the files to follow this naming convention:
01_A.jpg
01_B.jpg
02_A.jpg
02_B.jpg
03_A.jpg
03_B.jpg
04_A.jpg
05_B.jpg
The A represents the front of the card scanned and B is the back of the card.
It would need to be a count loop. This is card 1A and 1B etc..
In the documentation example I copied this code for the script:
var str = index % 2 ? 'B' : 'A';
I cant figure out the counter loop
As an idea it would be like
count = 0
var i = index % 2 ? (count + 1)+'B' : (count +1)+'A';
It needs to be in a loop
Any ideas would be appreciated!
-Thank you
Hi Nathan,
Given your example files (and assuming the flip sides are together in the ascending numeric order) you really only need this:
str = index % 2 ? 'B' : 'A'
base = ( "0000" + Math.ceil( ((index+1)/2) ) ).substr( -4 ) ;
return base + '_' + str;
The second line just divides the current number (index + 1) by 2 and rounds up if it's not an integer. Giving you the sequence 1, 1, 2, 2, etc. I padded it with zeros to four digits, so you'd have enough room for 1000 cards times 2 sides.
Best,
DF
Given your example files (and assuming the flip sides are together in the ascending numeric order) you really only need this:
str = index % 2 ? 'B' : 'A'
base = ( "0000" + Math.ceil( ((index+1)/2) ) ).substr( -4 ) ;
return base + '_' + str;
The second line just divides the current number (index + 1) by 2 and rounds up if it's not an integer. Giving you the sequence 1, 1, 2, 2, etc. I padded it with zeros to four digits, so you'd have enough room for 1000 cards times 2 sides.
Best,
DF
Reply to #2:
Thank you!
Thank you!