File renaming order is inconsistent

Started by deb27, October 08, 2015, 07:30:40 PM

Previous topic - Next topic

deb27

I am trying to rename my files in the form:  YYYY_MMDD_string-nnnn where the nnnn is an incrementing number that will allow me to sort the files by name and have them end up in the correct chronological order.
The command I tried is:
exiftool -d %Y_%m%d_Canada%%-.4C.%%e "-filename<DateTimeOriginal" .

The result (which looks correct but isn't) looks like:
D:\pictures\2015\test>dir /B
2015_0813_Canada-0000.jpg
2015_0813_Canada-0001.jpg
2015_0813_Canada-0002.jpg
2015_0813_Canada-0003.jpg
2015_0813_Canada-0004.jpg
2015_0813_Canada-0005.jpg
2015_0813_Canada-0006.jpg
2015_0813_Canada-0007.jpg
2015_0907_Canada-0008.dng
2015_0907_Canada-0009.JPG
2015_0907_Canada-0010.dng
2015_0907_Canada-0011.jpg
2015_0907_Canada-0012.jpg
2015_0907_Canada-0013.jpg
2015_0907_Canada-0014.jpg
2015_0907_Canada-0015.jpg


The problem is that file 0003 was taken later than 0004 and therefore their order should be reversed.  See below:
exiftool -a -G1 -s -EXIF:DateTimeOriginal 2015_0813_Canada-0003.jpg
[ExifIFD]       DateTimeOriginal                : 2015:08:13 12:07:35

exiftool -a -G1 -s -EXIF:DateTimeOriginal 2015_0813_Canada-0004.jpg
[ExifIFD]       DateTimeOriginal                : 2015:08:13 12:07:14


Why are the files in the wrong order?

To make matters worse, I determined that the renaming is inconsistent. I did two more rename operations. This time I included the %H%M%S in the file name. Here's what I got. Note that in the first output, I didn't have the files sorted by name but you can see that -0004 has seconds=14 and -0003 has seconds=35. After the second rename command the files have switched number.

Now I'm completely baffled.

exiftool -d %Y_%m%d_%H%M%SCanada%%-.4C.%%e "-filename<DateTimeOriginal" .
    1 directories scanned
   16 image files updated

dir /B
2015_0813_110041Canada-0000.jpg
2015_0813_112342Canada-0001.jpg
2015_0813_120539Canada-0002.jpg
2015_0813_120714Canada-0004.jpg
2015_0813_120735Canada-0003.jpg
2015_0813_122329Canada-0005.jpg
2015_0813_122944Canada-0006.jpg
2015_0813_125058Canada-0007.jpg
2015_0907_160824Canada-0008.dng
2015_0907_160824Canada-0009.JPG
2015_0907_161008Canada-0010.dng
2015_0907_161008Canada-0011.jpg
2015_0907_161008Canada-0012.jpg
2015_0907_164121Canada-0013.jpg
2015_0907_164604Canada-0014.jpg
2015_0907_165813Canada-0015.jpg


exiftool -d %Y_%m%d_%H%M%S_Canada%%-.4C.%%e "-filename<DateTimeOriginal" .
    1 directories scanned
   16 image files updated


dir /B /O:N
2015_0813_110041_Canada-0000.jpg
2015_0813_112342_Canada-0001.jpg
2015_0813_120539_Canada-0002.jpg
2015_0813_120714_Canada-0003.jpg
2015_0813_120735_Canada-0004.jpg
2015_0813_122329_Canada-0005.jpg
2015_0813_122944_Canada-0006.jpg
2015_0813_125058_Canada-0007.jpg
2015_0907_160824_Canada-0008.dng
2015_0907_160824_Canada-0009.JPG
2015_0907_161008_Canada-0010.dng
2015_0907_161008_Canada-0011.jpg
2015_0907_161008_Canada-0012.jpg
2015_0907_164121_Canada-0013.jpg
2015_0907_164604_Canada-0014.jpg
2015_0907_165813_Canada-0015.jpg


Phil Harvey

ExifTool renaming order is consistent.  When processing files in a directory, ExifTool uses the native system directory order (on Mac and Linux, this is alphabetical; on Windows, it is probably the order of the entries in the FAT).  But you can use the -fileOrder option to specify any other order you want.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).