#1 : 19/01-19 21:19 Stefan
Posts: 2
|
Hey Guys,
i tried it in the last hours but my JavaScript is just to rusty to get a solution on my own and i was unable to find something on the net and maybe im already to deep inside the box to see a solution... I need to rename files like: 0001-Name_of_file.jpeg 0002-Name_of_file.jpeg 0003-Name_of_file.jpeg 0004-Name_of_file.jpeg 0005-Name_of_file.jpeg 0006-Name_of_file.jpeg To this schema: New_Name_001.jpeg New_Name_001v.jpeg New_Name_002.jpeg New_Name_002v.jpeg New_Name_003.jpeg New_Name_003v.jpeg They need to stay in the original order because they are pages. Has anyone a idea? |
#2 : 20/01-19 00:29 David Lee
Posts: 1125
|
Reply to #1:
Try this script: newName = "New_Name"; n = parseInt((item.name.split('-'))[0])+1; subscript = ""; if ((n % 2) == 1) {subscript = "v"}; return newName + "_" + ("00"+Math.floor((n)/2)).slice(-3) + subscript; Obviously, replace "New_Name" as appropriate. www.w3schools.com/jsref is a good source of help with the syntax. |
#3 : 20/01-19 12:17 Stefan
Posts: 2
|
Reply to #2:
David, thank you so much! Thats exactly the solution and i learned a lot - thank you! |