How to avoid duplicate filenames in scripting ?

Advanced Renamer forum
#1 : 28/12-16 03:33
Posts: 11
I have several folders with files like 01.jpg 02.jpg 03.jpg etc ...

Sometimes, they're in reverse order (67.jpg should be 01.jpg, 66.jpg should be 02.jpg etc) so I wrote this script :

I couldn't find a way to change the filenames before inverting the numbers to avoid the duplicate filename errors, except slightly changing the extension (from jpg to jpeg) or by using the replace method together with the script.

Nonetheless, I was wondering if there was a more elegant way to achieve this with only a script and without modifying the extension ...

28/12-16 03:33 - edited 28/12-16 03:45
#2 : 28/12-16 07:46
G. Lambany
G. Lambany
Posts: 187
Reply to #1:
Either rename while moving the files (batch mode = move) or add something to the filename that you remove with another method afterward. It's a two pass thing, but the scripting in AR can't control when the rename happens.. to my knowledge anyway

would have to be added as a feature in AR, with two pass renaming or something, or be handled externally either with something calling two different rename pass in command line, or script the whole rename into something else than AR.

BulkRename had similar problem, wonder why this wasn't fixed by design in the first place (special mode with two pass rename, one that would add a very complex random code in the filename or a fixed code, to prevent collisions, then a second pass to the final filename)

for your script, you could use item.newBasename instead, to modify only the filename part, and not the extension, but anyway, doesn't change much.


28/12-16 07:46
#3 : 28/12-16 11:11
Posts: 11
Reply to #2:

True, a second button for a second pass script below the pre-batch script button would be a nice feature to have and doesn't sound like it would be very difficult to implement.
Well, I guess I'll just have to stick with a 2 method solution until then ...

28/12-16 11:11