Changing created date based on filename: Files are skibed and time is off

Started by madseeng, September 09, 2019, 06:05:34 PM

Previous topic - Next topic

madseeng


Hi
My motivation for seeking out exiftool: I usually use the date and time in the filename to easily sort photos and videos chronologically. But when backing up to google photos I cannot sort alphabetically but only by date ('date taken' for .jpg and 'media created' for .mp4). A problem since I compress video after capture.

I have about 10000 photos in 44 different folders with name and structure as shown below:
---------------------
D:\Photos
2018 01 - Skiferie Trysil
  2018-01-26 10.56.22 - Skitur-Trysil.mp4
  ...
2018 08 - US-Canada
  20GOPR0001.mp4
  ...
  2018-07-20 06.04.36 - Arizona.jpg
  ...
2019 07 - Norge-Sverige Tur
  2019-06-24 12.15.24 - Norge-Sverige Tur.jpg
  2019-06-24 19.11.23 - Norge-Sverige Tur.mp4
  ...
---------------------
As shown there are some outlighers but most follow the naming structure of: "YYYY-MM-DD HH.MM.SS - Keyword". Most of the pictures are GPS tracked aswell.

For simplicity I'd like to change all dates regarding the file to match the filename. I have been somewhat successful in this using the following command:
exiftool "-alldates<Filename" -overwrite_original -r "D:\Photos"

I have two major issues almost half of the files were skibet and all video files are 1 or 2 hours off.

Here are some examples of how the files are off:
"2019-06-24 19.11.23 - Norge-Sverige Tur.mp4" Was changed to 2019-06-24 21.11 (+2 hrs)
"2018-01-26 10.56.22 - Skitur-Trysil.mp4"  to  2018-01-26 11.56 (+1 hrs)
"2016-02-08 11.38.23 - New-zealand-waiheke.mp4" to 2018-02-08 12.38 (+1 hrs)
"2014-06-01 12.26.08 - Trend.mp4" to 2014-06-01 14.26 (+2hrs)

Regarding the skibbed files i get a bunch of errors like this:

Warning: File format error - D:/Photos/2016 02 - New Zealand/._2016-02-04-.14.2459---dubai.jpg
Error: Not a valid JPG - D:/Photos/2016 02 - New Zealand/._2016-02-04-.14.2459---dubai.jpg

How ever this file is in fact called "2016-02-04 14.24.59 - Dubai.jpg"

Any help in addressing these two problems (though more might arise) would be appreciated.




StarGeek

Quote from: madseeng on September 09, 2019, 06:05:34 PM
I have two major issues almost half of the files were skibet and all video files are 1 or 2 hours off.
Here are some examples of how the files are off:
"2019-06-24 19.11.23 - Norge-Sverige Tur.mp4" Was changed to 2019-06-24 21.11 (+2 hrs)
"2018-01-26 10.56.22 - Skitur-Trysil.mp4"  to  2018-01-26 11.56 (+1 hrs)
"2016-02-08 11.38.23 - New-zealand-waiheke.mp4" to 2018-02-08 12.38 (+1 hrs)
"2014-06-01 12.26.08 - Trend.mp4" to 2014-06-01 14.26 (+2hrs)

If the difference is "off" by the time zone, then exiftool is correctly writing the time.  In video files, according to the spec, the CreateDate time stamps is set to UTC time.  See the 4th paragraph under Quicktime tags

Now, depending upon the software you use, there could be good reasons for setting it to local time instead of UTC time.  Adobe products, for example, read the time stamp incorrectly and you might want to change it to sort correctly in a time line.  I don't recall off hand if Google Photos reads it correctly or not.  But if you try to sort the files by date on the Windows Desktop, then they will be out of order because Windows (for once) actually does read the time stamp correctly and adjust accordingly. 

If you decide you want the video files to have the time stamp in local time rather than UTC time, then you will have to issue a different command for the video files
exiftool "-alldates<Filename"  -ext mov -ext mp4 -api QuicktimeUTC -overwrite_original -r "D:\Photos"
The -api QuicktimeUTC option will disable the adjustment of the timestamp to UTC.  The addition of the -ext (extension) option will limit the command to only MP4 and MOV files.

QuoteWarning: File format error - D:/Photos/2016 02 - New Zealand/._2016-02-04-.14.2459---dubai.jpg
Error: Not a valid JPG - D:/Photos/2016 02 - New Zealand/._2016-02-04-.14.2459---dubai.jpg

How ever this file is in fact called "2016-02-04 14.24.59 - Dubai.jpg"

That is odd.  It seems likely that there may be hidden characters or non-ascii characters in that file name.  Assuming you're on Windows, Windows works poorly with regards to non-ascii characters at the best of times.  Try this command on that file and copy/paste the output here.
exiftool -j -filename "D:/Photos/2016 02 - New Zealand/*Dubai*"
This command will list the filename in json, which may show hidden characters. 
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

madseeng

Thanks this solved all my problems!

About the time zone. Your command worked wonders!
Quoteexiftool "-alldates<Filename"  -ext mov -ext mp4 -api QuicktimeUTC -overwrite_original -r "D:\Photos"
And I didn't have a single unexpected error. I'm not sure how it worked though since they were all compressed in Denmark, they don't contain GPS data and the amount of time the video files were off didn't seem to correspond to the time zone they were originally taken in:

Norge-Sverige +2hrs ≠ Norway and Sweden UTC+1
Skitur-Trysil +1hrs = Norway UTC+1
New-zealand-waiheke +1hrs ≠ New Zealand UTC+12
Trend +2hrs ≠ Denmark UTC+1

However this doesn't really matter since you solved my problem.

Using the command you suggested in regards to the misread files also worked.
Quoteexiftool -j -filename "D:/Photos/2016 02 - New Zealand/*Dubai*"
But more importantly it made me realize that exiftool was reading hidden files. I have no idea how they were created and why some folders had non and others 3 times as many hidden files as actual pictures. The ".-" is a typical indicator of hidden files on a mac (which I use primarily).