Need help with script rename

Advanced Renamer forum
#1 : 13/11-22 15:13
gregfwewef
Posts: 2
I have files like this:

File01
File02
File03
File04
File05
File06

I need rename it to this:

File01_Page1
File01_Page2
File02_Page1
File02_Page2
File03_Page1
File03_Page2

How can i do this?

I Use this script

odd = !odd;
var str = odd ? 'Page2' : 'Page1';
var n = 1
return item.newBasename + '_' + str;

to get

File01_Page1
File02_Page2
File03_Page1
File04_Page2
File05_Page1
File06_Page2

But how i can get?

File01_Page1
File01_Page2
File02_Page1
File02_Page2
File03_Page1
File03_Page2
#2 : 13/11-22 16:02
David Lee
Posts: 1125
Try this:

match = item.name.match(/(.*?)(\d*$)/);
if (match){
n = +match[2];
file = (Math.floor((n+1)/2));
page = ((n-1)%2 + 1);
return match[1] + ("0" + file).slice(-2) + "_Page" + page;
}
#3 : 13/11-22 21:32
gregfwewef
Posts: 2
Reply to #2:
Thank you so much!