#1 : 03/10-20 07:09 Styb
Posts: 110
|
I have several hundred files as follow:
001.jpg 001x.jpg 002.jpg 002x.jpg 003.jpg 003x.jpg etc. etc. where x indicates a random capital or small letter. I would like to rename 001.jpg to 001x.jpg and 001x.jpg to 001.jpg, etc. etc. How can I set up Advanced Renamer to achieve this? |
#2 : 03/10-20 09:39 David Lee
Posts: 1125
|
You need to clarify your problem. Is "x" the same random character in each case or will it vary between file pairs?
Do you mean... 001.jpg <--> 001x.jpg 002.jpg <--> 002y.jpg 003.jpg <--> 003z.jpg ? |
#3 : 03/10-20 09:39 David Lee
Posts: 1125
|
|
#4 : 03/10-20 09:52 Styb
Posts: 110
|
Reply to #3:
Hello David, it vary between file pairs. |
#5 : 03/10-20 10:37 David Lee
Posts: 1125
|
Reply to #4:
Add all your files to the list and re-order in descending order so that 003x.jpg lies above 003.jpg etc Then, using a script, if a suffix is present save it and append a temporary character (eg #) otherwise append the suffix saved from the previous file. Finally use a replace method to remove suffixes followed by #. You will need to carry out this step in a separate pass to avoid "File already exists" errors. Pass 1 script... Pre batch script: var suffix = ""; Main script: name = item.name; match = name.match(/(\d*)([^\d]?)$/); if (match[2]) { suffix = match[2]; return name + "#"; } else return match[1] + suffix; Run the batch, re-adding all your files. Pass 2... Replace: .*# With: nothing Use regular expressions |
#6 : 03/10-20 11:31 Styb
Posts: 110
|
Reply to #5:
My results: https://postimg.cc/JszJ6zq5 I have to rename eg 003.jpg to 003z.jpg, and 003z.jpg to 003.jpg It seems the script is not for that. Am I doing something wrong? |
#7 : 03/10-20 16:18 David Lee
Posts: 1125
|
Reply to #6:
You didn't read my instructions! "Add all your files to the list and re-order in descending order so that 003x.jpg lies above 003.jpg etc" The batch operates on the files in the order top to bottom. Click on the "Filename" column heading to reverse the order in the list. |
#8 : 03/10-20 16:57 Styb
Posts: 110
|
Reply to #7:
Thank you very much, it works as expected. |