If I rename images via exiv to the exif date time, I do the following:
find . -iname \*jpg -exec exiv2 -v -t -r '%Y_%m_%d__%H_%M_%S' rename {} \;
Now it might happen that pictures have exactly the same timestamp (including seconds). How can I make the filename unique automatically?
The command should be stable in the sense that if I execute it on the same directory structure again (perhaps after adding new pictures), the pictures already renamed shouldn't change and if pictures with already existing filenames are added the new filenames should be unique as well.
My first attempt was just to leave the original basename in the resulting filename, but then the command wouldn't be stable in the sense above.
Best Answer
You may want to try
jhead
instead which does that out-of-the-box (witha
,b
...z
suffixes allowing up to 27 files with the same date) and doesn't have the stability issue mentioned by @meuh:Or using
exiftool
(example in man page):(here with
%-c
being a numerical suffix starting with-
)