I have a large number of files for which i need to udpate CreateDate / alldates to include the correct timezone information. The issue is that where i live (Toronto) time zone changes from EST (-05:00) to EDT (-04:00) depending on time of the year and according to daytime saving schedule.
Is there a way to do this on a bulk number of files or am i obliged to filter them into two buckets (seems very time consuming!). My files have the local day time as part of the name YYYYmmdd_HHMMSS_makemodel_author
I am using this script to assign correct datetime with timezone to my media files:
# custom tag MyDateTimeFromFileName defined in my Exiftool_Config returns value "YYYY:mm:dd HH:MM:SS".
# seems to work better than using '<filename' for QuickTime:*Date datetime tags.
# TODO: check if this also works '-CreationDate<${FileName;s/^(\d{14}).*/$1'$par_TimeZone'/}'
par_DateTime=MyDateTimeFromFileName
par_TimeZone="-04:00"
exiftool \
-'alldates<${'$par_DateTime'}'$par_TimeZone \
-'QuickTime:*Date<${'$par_DateTime'}'$par_TimeZone \
-'FileModifyDate<${'$par_DateTime'}'$par_TimeZone \
-'FileCreateDate<${'$par_DateTime'}'$par_TimeZone \
-api QuickTimeUTC \
-progress \
-overwrite_original \
-r \
./
Appreciate help on this :(!
note: daytime saving schedule for Toronto 2010-2019: a mess :D!
2010 Sun, Mar 14 at 2:00 am EST → EDT
Sun, Nov 7 at 2:00 am EDT → EST
2011 Sun, Mar 13 at 2:00 am EST → EDT
Sun, Nov 6 at 2:00 am EDT → EST
2012 Sun, Mar 11 at 2:00 am EST → EDT
Sun, Nov 4 at 2:00 am EDT → EST
2013 Sun, Mar 10 at 2:00 am EST → EDT
Sun, Nov 3 at 2:00 am EDT → EST
2014 Sun, Mar 9 at 2:00 am EST → EDT
Sun, Nov 2 at 2:00 am EDT → EST
2015 Sun, Mar 8 at 2:00 am EST → EDT
Sun, Nov 1 at 2:00 am EDT → EST
2016 Sun, Mar 13 at 2:00 am EST → EDT
Sun, Nov 6 at 2:00 am EDT → EST
2017 Sun, Mar 12 at 2:00 am EST → EDT
Sun, Nov 5 at 2:00 am EDT → EST
2018 Sun, Mar 11 at 2:00 am EST → EDT
Sun, Nov 4 at 2:00 am EDT → EST
2019 Sun, Mar 10 at 2:00 am EST → EDT
Sun, Nov 3 at 2:00 am EDT → EST
Your system should know the time zone and when the daylight savings time changes occur. If it doesn't then you are either using an old system or your system time zone is set incorrectly.
With the system time zone set properly, you should just write the times without a time zone and the proper time zone will be assumed -- it will use DST if necessary depending on the date/time.
For example, on MacOS with my time zone set to EST5EDT:
> exiftool a.mov -api quicktimeutc -quicktime:createdate="2020:07:01 02:03:04"
1 image files updated
> exiftool a.mov -api quicktimeutc -quicktime:createdate
Create Date : 2020:07:01 02:03:04-04:00
> exiftool a.mov -api quicktimeutc -quicktime:createdate="2020:01:01 02:03:04"
1 image files updated
> exiftool a.mov -api quicktimeutc -quicktime:createdate
Create Date : 2020:01:01 02:03:04-05:00
This technique should also work for the filesystem date/time tags (and anything else that is stored internally as UTC), but other tags such as XMP and EXIF need to have the time zone specified explicitly -- for these you can do a second pass and take the date/time from a system tag.
- Phil
Quote from: Phil Harvey on November 09, 2021, 10:13:30 PM
If it doesn't then you are either using an old system or your system time zone is set incorrectly.
FAT32 file system, which would fall under old systems, doesn't deal with time zones if I recall correctly.
An example of Phil's suggestion of two passes. First set the file system tags
exiftool '-File*Date<${'$par_DateTime'}' /path/to/files/Then set all the others off of those
exiftool 'AllDates<FileModifyDate' /path/to/files/
Thank you very much. Will try and report back!
Using ssh on Western Digital My Cloud 3TB NAS.
OS: Linux WDMyCloud 3.2.26 #1 SMP Thu Jul 9 11:14:15 PDT 2015 wd-2.4-rel armv7l GNU/Linux
OS does not have a direct TimeZone change through bash (command not included), but only through web interface.
(//)
Quote from: StarGeek on November 09, 2021, 11:36:33 PM
FAT32 file system, which would fall under old systems, doesn't deal with time zones if I recall correctly.
Indeed, it doesn't! It's a purely local-time-based time. Heck, when you switching to/from DST, all times seem to shift by an hour as well! A truly horrible and outdated file system :-X
Much appreciated for your help. File system is ext3, lucky it isn't fat32 ;) ! Here is what worked for me:
$exift '-FileModifyDate<filename' ./
$exift -api quicktimeutc -'quicktime:createdate<FileModifyDate' -P ./
Actually doing -'quicktime:createdate<filename' also worked fine and does not remove the quicktime tag.
However, -'alldates<FileModifyDate' tends to create three new XMP tags DateTimeOriginal, CreateDate, and ModifyDate and remove QuickTime:ModifyDate tag. Not sure whether this is a good or a bad thing!
Wish there was a standardized well defined timezone tag! i have a large number of media files to organize and set correct file names / time stamps for. Having to change the system timezone to handle certain media files of a different timezone (say UK, France, etc) is just a lot of manual work to do down the road :(
Ideally I am naming all my media files in using their original local datetime value
YYYYmmdd_HHMMSS_subsec_Resolution_Make_Model_Author.ext
This helped me so far remove many many duplicates. The key is to get the correct local datetime tag, update file name accordingly, then update alldates to the correct dateime without affecting original media timezone value. will share once i land on a single script to get it done...
Thanks again for the quick and very helpful info.
Quote from: issam9973 on November 11, 2021, 10:37:08 PM
However, -'alldates<FileModifyDate' tends to create three new XMP tags DateTimeOriginal, CreateDate, and ModifyDate and remove QuickTime:ModifyDate tag. Not sure whether this is a good or a bad thing!
It doesn't remove it. See FAQ 3 (https://exiftool.org/faq.html#Q3).
- Phil
Quote from: issam9973 on November 11, 2021, 10:37:08 PM
However, -'alldates<FileModifyDate' tends to create three new XMP tags DateTimeOriginal, CreateDate, and ModifyDate and remove QuickTime:ModifyDate tag. Not sure whether this is a good or a bad thing!
If you want to only edit only the Quicktime tags and not create XMP tags, you can use
'-Quicktime:AllDates<FileModifyDate'.
Example:
C:\>exiftool -P -overwrite_original -all= Y:\!temp\Test1.mp4
1 image files updated
C:\>exiftool -P -overwrite_original -Quicktime:AllDates=now Y:\!temp\Test1.mp4
1 image files updated
C:\>exiftool -time:all --system:all -G1 -a -s Y:\!temp\Test1.mp4
[QuickTime] CreateDate : 2021:11:12 08:13:09
[QuickTime] ModifyDate : 2021:11:12 08:13:09
[Track1] TrackCreateDate : 0000:00:00 00:00:00
[Track1] TrackModifyDate : 0000:00:00 00:00:00
[Track1] MediaCreateDate : 0000:00:00 00:00:00
[Track1] MediaModifyDate : 0000:00:00 00:00:00
[Track2] TrackCreateDate : 0000:00:00 00:00:00
[Track2] TrackModifyDate : 0000:00:00 00:00:00
[Track2] MediaCreateDate : 0000:00:00 00:00:00
[Track2] MediaModifyDate : 0000:00:00 00:00:00
[UserData] DateTimeOriginal : 2021:11:12 08:13:09-08:00[/code[
Thanks Phil and StarGeek, that was quite helpful. I did some more readings, including FAQ 3 and MWG tags, and i think the following code seems to solve what i intend to do. Will appreciate much an expert eye to check and spot any wrong step i might have made.
Problem statement: I have a good number of media files with timezone info corrupted to EST/EDT (my fault from running custom previous exiftool scripts without paying attention to timezone peculiarities). It seems my files have the correct local date time the filename (and other datetime tags). Intention is to correct the timezone info and set all datetime fields to the correct value without having to change system timezone!
Solution?: used script below, which later i might adjust to an automated form after manually sorting out files into 'timezone' folders. So far i am looking at all MP4 files, will extend later to the other media types.
#### Change TimeZone ONLY ####
par_date="MyDateTimeFromFileName"
par_TimeZone="+01:00"
$exift -api quicktimeutc '-alldates<${MyDateTimeFromFileName}'$par_TimeZone -P -r ./
$exift -api quicktimeutc '-QuickTime:Time:all<${MyDateTimeFromFileName}'$par_TimeZone -P -r ./
$exift '-FileModifyDate<CreateDate' ./
Existing Tags
I got all date tags updated with some new XMP tags created, which i'm totally fine with:
# existing tags
exiftool -a -time:all -s -G1 ./
======== ./20130825_133531.MP4
[System] FileModifyDate : 2013:08:25 13:35:31-04:00
[QuickTime] CreateDate : 2013:08:25 13:35:31-04:00
[QuickTime] ModifyDate : 2013:08:25 13:35:31-04:00
[Track1] TrackCreateDate : 2013:08:25 13:35:31-04:00
[Track1] TrackModifyDate : 2013:08:25 13:35:31-04:00
[Track1] MediaCreateDate : 2013:08:25 13:35:31-04:00
[Track1] MediaModifyDate : 2013:08:25 13:35:31-04:00
[Track2] TrackCreateDate : 2013:08:25 13:35:31-04:00
[Track2] TrackModifyDate : 2013:08:25 13:35:31-04:00
[Track2] MediaCreateDate : 2013:08:25 13:35:31-04:00
[Track2] MediaModifyDate : 2013:08:25 13:35:31-04:00
[Composite] MyDateTimeFromFileName : 2013:08:25 13:35:31
Updated Tags
Updated existing Tags: i assume internal encoding is correct since my current filesystem is EST (Toronto).
exiftool -a -time:all -s -G1 ./
======== ./20130825_133531.MP4
# Updated existing Tags
[System] FileModifyDate : 2013:08:25 08:35:31-04:00
[QuickTime] CreateDate : 2013:08:25 08:35:31-04:00
[QuickTime] ModifyDate : 2013:08:25 08:35:31-04:00
[Track1] TrackCreateDate : 2013:08:25 08:35:31-04:00
[Track1] TrackModifyDate : 2013:08:25 08:35:31-04:00
[Track1] MediaCreateDate : 2013:08:25 08:35:31-04:00
[Track1] MediaModifyDate : 2013:08:25 08:35:31-04:00
[Track2] TrackCreateDate : 2013:08:25 08:35:31-04:00
[Track2] TrackModifyDate : 2013:08:25 08:35:31-04:00
[Track2] MediaCreateDate : 2013:08:25 08:35:31-04:00
[Track2] MediaModifyDate : 2013:08:25 08:35:31-04:00
[Composite] MyDateTimeFromFileName : 2013:08:25 13:35:31
New Tags added by Exiftool
# New Tags added by Exiftool
[ItemList] ReleaseDate : 2013:08:25 13:35:31+01:00
[ItemList] ContentCreateDate : 2013:08:25 13:35:31+01:00
[UserData] DateTimeOriginal : 2013:08:25 13:35:31+01:00
[Microsoft] EncodingTime : 2013:08:25 08:35:31-04:00
[Microsoft] DateAcquired : 2013:08:25 13:35:31
[Keys] CreationDate : 2013:08:25 13:35:31+01:00
[Keys] LocationDate : 2013:08:25 13:35:31+01:00
[Keys] Year : 2013:08:25 13:35:31+01:00
[XMP-exif] DateTimeOriginal : 2013:08:25 13:35:31+01:00
[XMP-xmp] CreateDate : 2013:08:25 13:35:31+01:00
[XMP-xmp] ModifyDate : 2013:08:25 13:35:31+01:00
Much thanks for the patience of reading through till here :D!
Quote from: issam9973 on November 14, 2021, 09:17:35 PM
$exift -api quicktimeutc '-alldates<${MyDateTimeFromFileName}'$par_TimeZone -P -r ./
$exift -api quicktimeutc '-QuickTime:Time:all<${MyDateTimeFromFileName}'$par_TimeZone -P -r ./
These may be executed as one command:
$exift -api quicktimeutc '-alldates<${MyDateTimeFromFileName}'$par_TimeZone '-QuickTime:Time:all<${MyDateTimeFromFileName}'$par_TimeZone -P -r ./
Quote
exiftool -a -time:all -s -G1 ./
======== ./20130825_133531.MP4
# Updated existing Tags
[System] FileModifyDate : 2013:08:25 08:35:31-04:00
[QuickTime] CreateDate : 2013:08:25 08:35:31-04:00
You must have used the QuickTimeUTC here to get a time zone on the QuickTime tag. Are you setting QuickTimeUTC in a config file?
- Phil
Thanks Phil, good catch 8)! i am now using -time:all instead of -alldates.
Yes for QuickTimeUTC, just added it this morning to .ExifTool_config file after seeing it in one of the forum pages:
%Image::ExifTool::UserDefined::Options = (
LargeFileSupport => 1,
QuickTimeUTC => 1,
);
Quote from: issam9973 on November 14, 2021, 10:44:26 PM
Thanks Phil, good catch 8)! i am now using -time:all instead of -alldates.
Are you using
Time:All or
QuickTime:Time:all?
I would not suggest using
Time:All by itself. It will set a total of 94 time related tags, many of which will be completely useless. For example,
Time:All will set a couple of
XMP-pdf tags, but a video or image isn't a PDF. Also a
XMP-getty tag, which is unnecessary outside of GettyImages. That's just a few of the many specialty tags that would be set.
Thanks StarGeek, Will do.
Exiftool is just awesome! will continue learning for sure.