node-exif-renamer icon indicating copy to clipboard operation
node-exif-renamer copied to clipboard

Adding auto-incrementing collision template pattern

Open bbugh opened this issue 6 years ago • 4 comments

Seems to be related to #9 but I can't tell what the resolution of that was, as I can't find anything about collisions except possibly using file which isn't ideal for my use case. I don't care about the original filename.

Issue Our Android phone isn't saving photos with exif data nor is it saving the seconds in the creation time. So, attempting to use exif-renamer on these Android photos that were all captured on the same minute results in many collisions. --overwrite won't work in this case, because they're unique images.

Solution

Ideally, there would be an auto-increment number option that would activate if there was a name collision. Something like:

photo_20171123-165023.jpg
photo_20171123-165023-2.jpg

bbugh avatar Nov 23 '17 17:11 bbugh

I would have expected the resolution to #9 to solve this. Here is the test I wrote waaaay back then: https://github.com/dylansmith/node-exif-renamer/commit/6eb204261c0f584318153492acd6a90027075b9a#diff-a6e05095d2e2f527c13bad5d2b68cf28R358.

It's possible that I haven't tested your particular case; do you think you could describe a test that would cover it?

dylansmith avatar Nov 24 '17 12:11 dylansmith

That definitely would do it! However, the latest published version is 1.1.2, and that is 1.2.0, so it looks like it never actually made it out into the package managers. Any chance you want to ship it?

bbugh avatar Nov 24 '17 13:11 bbugh

Ah, well, almost. If I run exif-renamer multiple times on the same directory, existing already renamed files are renamed with the incremented name. If I run it again, they're de-incremented because the name doesn't exist again. It seems like it should check to see if the new name matches the old name, and skip it if so.

Example renaming back and forth:

> exif-renamer -t 'photo_{{datetime "mm-dd-yyyy_hh.MM.sstt"}}.{{ext}}' photo_06-14-2017_02.50.19pm.jpg
photo_06-14-2017_02.50.19pm.jpg ➔ photo_06-14-2017_02.50.19pm(1).jpg
> exif-renamer -t 'photo_{{datetime "mm-dd-yyyy_hh.MM.sstt"}}.{{ext}}' photo_06-14-2017_02.50.19pm(1).jpg
photo_06-14-2017_02.50.19pm(1).jpg ➔ photo_06-14-2017_02.50.19pm.jpg

I realize you haven't done anything with this in two years and I'm resurrecting an old project, but it's just so damn helpful with this giant mountain of family photos I have from so many different sources. I really appreciate this.

bbugh avatar Nov 24 '17 14:11 bbugh

Ah, I see. I'll have to parse the increment from the original filename and re-apply it in the output. Nice find, thanks.

dylansmith avatar Nov 24 '17 16:11 dylansmith