Rename or Renumber

Advanced Renamer forum
#1 : 24/12-19 07:03
Sumit Simlai
Sumit Simlai
Posts: 2
Hi

I purchased this software and find it extremely useful. But sometimes, like now, I get badly stuck, especially when I have a project to deliver.

I have a list of 500 files with names odd_page_001, odd_page_002, odd_page_003, odd_page_004 and so on, up to odd_page_500. I have another set of 500 files with names even_page_001, even_page_002, even_page_003, even_page_004 and so on, up to even_page_500.

I have to finally mix these pages so that when I create a pdf I get alternate odd-even-odd-even.... Hope you understand.

My problem now is, I need to rename or renumber the files such that the first lot, the odd lot appears as odd_page_001, odd_page_003, odd_page_005, odd_page_007 and so on, while those in the even lot appear as even_page_002, 004,.,..

I am unable so simply get what syntax to use for the renaming.

Any help would be fantastic.


24/12-19 07:03
#2 : 26/12-19 18:10
David Lee
David Lee
Posts: 1125
Try this script:

regex = /([^_]*)(.*_)(.*)/;
str = item.name;
if (regex.test(str)){
match = str.match(regex);
if (match[1] == "odd"){
return match[1] + match[2] + (2 * match[3]-1);
} else if (match[1] == "even"){
return match[1] + match[2] + (2 * match[3]);
}
}

This script will return page numbers without zero padding. Unfortunately Advanced Renamer renames files one at at time so if you try to return zero padded results you will fall foul of "collisions" each time the script tried to rename a file to the same original name as another file in the list.

If you wish to retain zero-padded page numbers then you will have to re-pad in a separate batch using the Renumber method:

Number position: 1
Change to: Relative to existing number
Number difference = 0
Zero padding: Manual
Number length = 3


Please let me know it it works for you.


26/12-19 18:10 - edited 26/12-19 18:48
#3 : 13/01-20 22:19
Sumit Simlai
Sumit Simlai
Posts: 2
Reply to #2:
Hi thanks for your reply and really sorry for so late a reply. I have been tied up in moving apartments.

Well, now things are a bit different and I have landed into a different situation altogether. I have a set of the same 500 jpeg files numbered 001 through to 500. These are pages from a book I scanned.

In order to edit the jpeg using different software before I combine them into a book. I need to segregate these jpeg files into separate odd and even ones, by suitably renaming them and then using the right filters in Windows Explorer to push the odd ones into a folder called ODD and the even ones into a folder called EVEN.

Then later once I have finished editing those files (jpeg) I need to merge them back to finally get my book.

Thanks in advance.


13/01-20 22:19
#4 : 14/01-20 10:57
David Lee
David Lee
Posts: 1125
Reply to #3:

Advanced Renamer can divide your files into ODD and EVEN folders using a simple script:

if (item.name % 2) {
dir = "\ODD";
} else {
dir = "\EVEN";
}
item.newPath = item.path + dir;


"%" is the Modulus operator -ie the remainder after division by the second argument.
So "item.name % 2" will be zero if the filename is an even number and unity if it is odd.



14/01-20 10:57 - edited 14/01-20 13:08
#5 : 14/01-20 13:15
David Lee
David Lee
Posts: 1125
Reply to #4:
I may have misinterpreted your last message. In my previous reply I was assuming that your filenames are simply sequential page numbers - ie 001.jpeg - 500.jpeg

If you are starting with exactly the same filenames as in your original problem then modify my first script to set the respective values of newPath as follows:

regex = /([^_]*)(.*_)(.*)/;
str = item.name;
if (regex.test(str)){
match = str.match(regex);
if (match[1] == "odd"){
item.newPath = item.path + "\ODD";
return match[1] + match[2] + (2 * match[3]-1);
} else if (match[1] == "even"){
item.newPath = item.path + "\EVEN";
return match[1] + match[2] + (2 * match[3]);
}
}


14/01-20 13:15 - edited 14/01-20 13:18