Name collision rule: Append incrementing number
Hey,
it's a repost, because I can't reply to the old post: https://www.advancedrenamer.com/forum_thread?forum_id=4444
I want to do the following:
As a name collision rule, I want to append an incrementing number.
Example:
Foo.txt
Foo.txt
Bar.txt
Bar.txt
Bar.txt
The resulting names should be:
Foo.txt
Foo_1.txt
Bar.txt
Bar_1.txt
Bar_2.txt
With “Append incrementing number” I'm getting:
Foo.txt
Foo_001.txt
Bar.txt
Bar_001.txt
Bar_002.txt
How can I achieve that, without running Advanced Renamer a second time to remove the “00”?
it's a repost, because I can't reply to the old post: https://www.advancedrenamer.com/forum_thread?forum_id=4444
I want to do the following:
As a name collision rule, I want to append an incrementing number.
Example:
Foo.txt
Foo.txt
Bar.txt
Bar.txt
Bar.txt
The resulting names should be:
Foo.txt
Foo_1.txt
Bar.txt
Bar_1.txt
Bar_2.txt
With “Append incrementing number” I'm getting:
Foo.txt
Foo_001.txt
Bar.txt
Bar_001.txt
Bar_002.txt
How can I achieve that, without running Advanced Renamer a second time to remove the “00”?
The Collision Rule will always zero-pad an incrementing number to at least 3 digits.
The easiest solution is to automatically reload all the files, when you run the batch, and then remove the zero-padding using a Renumber method.
Otherwise, if you want to avoid the use of a second pass, you will need to create your own Collision Rule using a Script method.
Allocate an object in the Pre batch script, to keep track of duplicate filenames:
var names = {};
Then, in the main script:
name = item.newBasename;
if(names[name]) return name + names[name]++;
else names[name] = 1;
The easiest solution is to automatically reload all the files, when you run the batch, and then remove the zero-padding using a Renumber method.
Otherwise, if you want to avoid the use of a second pass, you will need to create your own Collision Rule using a Script method.
Allocate an object in the Pre batch script, to keep track of duplicate filenames:
var names = {};
Then, in the main script:
name = item.newBasename;
if(names[name]) return name + names[name]++;
else names[name] = 1;
Reply to #2:
My previous solution will consider identical filenames to be duplicates even if they have different extensions. To fix this, modify the main script as follows:
name = item.newName;
if(names[name]) return item.newBasename + names[name]++;
else names[name] = 1;
My previous solution will consider identical filenames to be duplicates even if they have different extensions. To fix this, modify the main script as follows:
name = item.newName;
if(names[name]) return item.newBasename + names[name]++;
else names[name] = 1;
Reply to #3:
Nice. Thanks for pointing out. I'll use the script then.
Nice. Thanks for pointing out. I'll use the script then.
Reply to #1:
You shouldn't want that, as you'll get unreliable sorting dependent on your OS of choice and its ability to differentiate between 1 and 10 (2 & 20, 3 & 30, ...)
You shouldn't want that, as you'll get unreliable sorting dependent on your OS of choice and its ability to differentiate between 1 and 10 (2 & 20, 3 & 30, ...)
Reply to #5:
I know. In my case, I don't have more than 10 files in one group.
I know. In my case, I don't have more than 10 files in one group.