Odd/Even Problem

Advanced Renamer forum
#1 : 09/03-24 08:51
Shawn K
Shawn K
Posts: 3
Good Evening Everyone,

My issue is that I have started with 49 PDFS, each file contains 2 pages (front/back). The only way I could think of to tackle this problem was to combine all of the PDFs and then re-export them in sequential order. So I have 98 individual pdfs, I need to order them in 1A, 1B, 2A , 2B, etc. I have used java to do odds/evens but that leaves me with a group of files that are 1A, 1B, 3A, 3B, 5A, etc.

Anyone have any pointers? Sorry If I'm missing something obvious, I've just been grinding my brain on this problem.

For reference, the software I am using requires a spreadsheet that matches 2 files, one for the front and one for the back. So I need 01_front.pdf, 01_back.pdf, and 01_list.xlsx, to all have the same naming structure.

Thanks,


09/03-24 08:51
#2 : 10/03-24 00:45
Delta Foxtrot
Delta Foxtrot
Posts: 285
Reply to #1:

I'm not sure I understand the question, but if I do here's something that should work for you.
Assuming, as you stated, pdf files named 1A, 1B, 3A, 3B, etc up to I assume 98B (or something like that):

script:
------------------------------------------------
var newNum = Math.ceil(parseInt(item.newBasename.slice(0,item.newBasename.length-1))/2) ;
var oldSide = item.newBasename.slice(item.newBasename.length-1);
var newSide = ""
if (oldSide == "A") newSide = "_Front";
else newSide = "_Back";
return newNum + newSide;
------------------------------------------------
EDIT: I screwed up cut and paste of the script the first time. Hope no one saw that. END EDIT

I keep thinking I must be missing something in your problem. If ***I*** can write javascript to do it I must not understand the problem! :)

EDIT: Oh, I just noticed I didn't prepend zeros on the returned filenames. END EDIT

Cheers,
DF


10/03-24 00:45 - edited 10/03-24 01:07
#3 : 10/03-24 03:53
Shawn K
Shawn K
Posts: 3
So I guess I worded my question poorly. My original files were 2 page PDFs (front & back), I combined them all together to batch edit them in InDesign then re-exported them back out as individual PDFs.

Using Advanced Renamer, I renamed the files sequentially so I have 01.pdf .... 98.pdf. All of my odd numbers are the fronts of the postcards and all the even numbers are the backsides.

I need to end up with 01_front.pdf, 01_back.pdf, etc. So right now 01.pdf is correct, but 02.pdf is really the backside of 01.

Hopefully that makes a little more sense. I think I might be able to use the index to do what I want...just looking for pointers.

Thanks,


10/03-24 03:53
#4 : 10/03-24 04:39
Shawn K
Shawn K
Posts: 3
Reply to #3:

I found a rather inelegant way to get it done, I figure I'd post it here just in case any one else gets stumped like me.

1) Take all the files and number them sequentially
2) Use script to rename all of the ODDS ##_Front, and all the EVENS ##_Back
suffix = index %2 ? '_BACK' : '_FRONT';
return item.newBasename + suffix;
3) Use filename mask to only select the _BACK files, renumber sequentially
4) Use filename mask to only select the _FRONT files, renumber sequentially

I don't know why I didn't think of that originally...


10/03-24 04:39
#5 : 10/03-24 08:01
Delta Foxtrot
Delta Foxtrot
Posts: 285
Reply to #4:

Hey Shawn,

Yeah, sometimes it takes looking at a problem for a while to get there. But results are what matters, elegance is just empty calories that make you feel fuller. I guess "icing on the cake" is a more elegant way to say that. :) Good work!

Best,
DF


10/03-24 08:01
#6 : 10/03-24 20:35
Miguel
Miguel
Posts: 136
Reply to #4:
You also can use the regex ^\d*[13579]$ for odd numbers or ^\d*[02468]$ for evens numbers.


10/03-24 20:35
#7 : 11/03-24 10:24
Styb
Styb
Posts: 101
Reply to #6:
In these cases, I use the explorer's search box at right corner of "Add files" dialog, by searching for A- or B-containing filenames.

My 2 cents. ;)


11/03-24 10:24 - edited 11/03-24 10:32