News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

FileModifyDate is off by one second sometimes

Started by jls3512, September 07, 2015, 09:28:28 AM

Previous topic - Next topic

jls3512

I don't really think this is as much a bug as it is probably something to do with windows, but it's curious behavior so I thought I would ask about it. 


I'm using the following batch file to make all the dates in my photos the same as the create date... the only date I will ever care about,  when the photo was taken.


@echo off
Echo %~D1%~P1
Echo %*
set /P offset=Enter offset including + or -:
if "%offset%"=="0" goto :setdates
if "%offset%"=="+0" goto :setdates
if "%offset%"=="-0" goto :setdates

exiftool.exe -ext .dng -ext .jpg -ext .mp4 -ext .tif -ext .psd "-CreateDate%offset:~0,1%=%offset:~1%" -r -Overwrite_original -progress -m %*


:setdates
exiftool.exe -ext .dng -ext .jpg -ext .mp4 -ext .tif -ext .psd "-DateTimeOriginal<CreateDate" "-TrackCreateDate<CreateDate" "-TrackModifyDate<CreateDate" "-MediaCreateDate<CreateDate" "-MediaModifyDate<CreateDate" "-SonyDateTime<CreateDate" "-ModifyDate<CreateDate" "-FileCreateDate<CreateDate" "-FileModifyDate<CreateDate" -k -r -Overwrite_original -progress -m -q %*



On some, but not all of the files, when I go back and look at them,  the FileModifyDate is advanced by one second.   I don't understand why, because both FileCreateDate and FileModifyDate are copied from CreateDate and therefore should be identical.   File Size seems to have no bearing on this effect, it does it on 25MB .dng files as well as 2MB .jpg files... and when looking even at files in the same folder, of photos taken seconds of each other,  one will display this one second advance in FileModifyDate and the other will not.   I also notice that files showing the one second advance will always have it no matter how many times I run them, and files that do not show it never will no matter how many times I run those either.  I also tried changing createdate ahead and back in various increments from 1 hour to 5 hours and that also has no effect.  Also file type seems to make no difference,  I have examples both ways of .dng .arw .jpg .tif and .psd


My computer is Window 7 Professional

relevant hard drives:
C:  O/S  512GB SSD formatted NTFS
L:   Photo Storage 5TB internal hard drive formatted EXFAT

exiftool version 10.01


Alan Clifford

Do windows filesystems still store their filestamps with a 2 second resolution?  FAT filesystems do I think.


Alan Clifford

Found this

https://support.microsoft.com/en-us/kb/127830

Hayo Baan

I think Alan already provided you the answer on why this could happen. I would only add that I would strongly suggest to not rely on the file system's timestamps at all as they can easily get changed by just "touching" the files (editing, moving, etc.). Instead, I suggest you use the metadata fields inside the files themselves (that's what they are for!).
Hayo Baan – Photography
Web: www.hayobaan.nl

jls3512

Thanks for the information!  I would have never guessed that they carried that over in the relatively new ExFAT file system, which is way newer than NTFS.  Apparently they round to the nearest 2 seconds only in the  Date modified and date access fields, but they upgraded the date created field allow 1 second resolution.   Strange.    Thanks for figuring this out!   

I agree about using metatags instead, and most of my files do use the metatags, but I have some MTS movie files created by my digital camera that I can't write any metadata into, and unfortunately I took a whole ton of photos with it not realizing that the GPS had not yet corrected my timezone,  so they are all 5 hours out of sync with the rest of my photos take with other cameras.   Fixing the file time stamps gives me an easy way to see where the time is going wrong so I can fix it, because the time should increment in the numerical order the photos and/or videos were taken.   Unfortunately I can't fix DateCreated metatag in the MTS files, because even though Exiftool can read this,  it can't write it and in fact, it won't even write out the file create, modify, and access dates on mts files.   I guess I'll have to convert them to .mp4 files or something eventually.

James

Phil Harvey

Hi James,

ExifTool should be able to write the filesystem date/time tags for any file type, but you need to either specify the file by name or add -ext m2t to the command if specifying a directory to get ExifTool to process the file.  (FAQ 16 explains why.)

- 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 ($).

jls3512

Thank you Phil, 

I did get it to work,  I figured I would post my findings so perhaps they will help someone else who was making the same error I was making.   Here's what was happening...
I was using this command:

exiftool.exe  -ext .dng -ext .jpg -ext .mp4 -ext .tif -ext .mts "-CreateDate<DateTimeOriginal" "-TrackCreateDate<DateTimeOriginal" "-TrackModifyDate<DateTimeOriginal" "-MediaCreateDate<DateTimeOriginal" "-MediaModifyDate<DateTimeOriginal" "-SonyDateTime<DateTimeOriginal" "-ModifyDate<DateTimeOriginal" "-FileCreateDate<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal" -k -r -Overwrite_original -progress -m -q %*

trying to correct all my metadata in all applicable file types in one pass.. 
TrackCreateDate,TrackModifyDate, MediaCreateDate, and MediaModifyDate only exist in my MP4 files
SonyDateTime only exist for 2 of my Sony cameras  .JPG and .DNG files
Create Date exists in all files except .MTS
and DateTimeOriginal exists in all files including .MTS

with this command when the .mts files went through, it saw tags it could not write to, so it gave an error:
Error: Writing of MTS files is not yet supported

so I figured it could not write to the .MTS files at all,  I did read in the forum somewhere that there is no standard for .MTS files so it's rather pointless to try to support something that has no standard format,  I also noticed that it did not write the FileCreateDate or FileModifyDate
the reason I incorrectly figured it could not write the FileCreateDate and FileModifyDates is because other files will just ignore tags they don't have and modify the ones they do,  so if I run my sony .DNG file through the above command,  it does fix the SonyDateTime,  CreateDate, FileCreateDate, and FileModifyDate, but it just ignores TrackCreateDate,TrackModifyDate, MediaCreateDate, and MediaModifyDate without any warnings or errors... when it gets an .MP4 it ignores SonyDateTime and writes all the rest... etc.. Since the .MTS file didn't write anything at all and said it was not supported, I didn't even think to try:

exiftool.exe  -ext .mts "-FileCreateDate<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal" -k -r -Overwrite_original -progress -m -q %*

which I just tried and I am very happy that it does indeed change FileCreateDate and FileModifyDate.

I was hoping to get it all done in one pass,  I had over 101,000 files to process, and it took a little over 10hours, and I'm happy to say that it worked perfectly on all but the .mts files which aren't really that many.    I can just do a dir *.mts /s /b > mtsfiles.txt and figure out where my .mts files are and just run those through a short run without going though them all again.

I'll be sure to take the -ext .mts off the original command line and add another line for just .mts files and it should be good.



Phil Harvey

Ah.  That makes sense.  Yes, ExifTool will balk when trying to write "real" tags to an unsupported file.

- 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 ($).