1
1
I have a folder with pictures taken with different cameras and all these pictures have a correct DateTimeOriginal EXIF tag set.
Suppose a list of files like this:
20150831_153712.jpg
IMG_5246.JPG
IMG_5247.JPG
20150902_201425.jpg
Now I would like to know how to rename those files in this way, based on the DateTimeOriginal tag of course:
001_IMG_5246.JPG
002_20150831_153712.jpg
003_IMG_5247.JPG
004_20150902_201425.jpg
Basically I want exiftool (or a Windows batch program if that's not possible directly) to sort the whole folder of JPEGs by DateTimeOriginal ascending and the renaming operation should put a counter prefix in front of the filename (thus retaining the original filename).
I would also like how to do a test command to preview the renaming before it occurs (to see if something is wrong, I suppose using the TestName tag).
It's almost perfect, thanks! But there are two quircks with 10 and 100 which have a leading 0 too much:
'20150831_124835.jpg' --> '009_20150831_124835.jpg', '20150831_131539.jpg' --> '0010_20150831_131539.jpg', 'IMG_5291.JPG' --> '099_IMG_5291.JPG', 'IMG_5292.JPG' --> '0100_IMG_5292.JPG', '20150901_170708.jpg' --> '101_20150901_170708.jpg'
. – virtualdj – 2015-09-12T18:50:16.050It's also worth noting that TestName tag has been introduced since version 9.64 of ExifTool (I was using an older version and it failed with a lot of
warning: no writable tags set from ****
messages). This may be useful to other users reading this answer. – virtualdj – 2015-09-12T18:53:36.313Ah, yes. That's because I measured the length of the number, and then added 1 to the number. My stupid mistake attempting to keep the advanced formatting as short as possible. Corrected the command. If you need to start at a different number, you need to correct both occurances of
($_+1)
. – StarGeek – 2015-09-12T20:47:44.883