hello

Advanced Renamer forum
#1 : 25/02-21 13:51
Kerem
Kerem
Posts: 4
Hello,
When we use the code in the Advanced renamer application, when we switch to a different file name, it does not count the numbers from the beginning.

Thanks.


25/02-21 13:51
#2 : 25/02-21 22:30
David Lee
David Lee
Posts: 1071
You will have to be a lot more specific if you want anyone to help you!


25/02-21 22:30
#3 : 03/03-21 21:02
Kerem
Kerem
Posts: 4
Reply to #2:

I can report the problem with the e-mail address screenshots.


03/03-21 21:02
#4 : 03/03-21 21:06
Kerem
Kerem
Posts: 4
Reply to #3:
sample
12345_1
12345_2
12345_3
43214_1
43214_2
43214_3
54321_1
54321_2
54321_3


How can I do that ?

Thanks...


03/03-21 21:06
#5 : 04/03-21 10:40
David Lee
David Lee
Posts: 1071
Reply to #4:
If you want people to help you then you really should take the trouble to explain clearly what you are trying to do!

However I assume that you have renamed your files in such a way that there are duplicate new names and you are using the default Collision Rule to append "_" plus an incrementing number .

If that is the case then you will have to add a Script method to add numbers starting from 1 for each new name.

Provided the NEW filenames are ordered such that duplicate filenames are all together in the list then the following code will work.

In the Pre-batch script:

lastName = "";

And in the main script window:

name = item.newBasename;
log(name);
if (name == lastName) {
n++;
} else {
lastName = name;
n = 1;
}
return name + '_' + n;



04/03-21 10:40 - edited 04/03-21 10:41
#6 : 05/03-21 10:12
David Lee
David Lee
Posts: 1071
Reply to #5:

The following code will work with the list in any order...

Pre-batch script:

var names = {};

Main script:

name = item.newBasename;
(n = names[name]) ? n++ : n = 1;
names[name] = n;
return name + '_' + n;


05/03-21 10:12 - edited 05/03-21 14:45