ExifTool Forum

ExifTool => Newbies => Topic started by: r2k on August 07, 2021, 12:27:22 PM

Title: change file date
Post by: r2k on August 07, 2021, 12:27:22 PM
Hi guys,

sorry this might be a real newbie question but the man page is just overwhelming ;-)

I want to change the file timestamps from all my mov files (*.mov) to the real creation date

Which command to use pls?

cli on mac 10.5.1 (v 12.26)

Thx
Title: Re: change file date
Post by: StarGeek on August 07, 2021, 01:08:22 PM
First you have to figure out what tag holds the "real creation date".  Run this command on a file to list all the time related tags
exiftool -api QuickTimeUTC -time:all -G1 -a -s file.mp4
       Edited to add api option as shown in example below
You'll get something like this
C:\>exiftool -time:all -api QuickTimeUTC -G1 -a -s Y:\!temp\Test1.mp4
[System]        FileModifyDate                  : 2021:05:07 11:48:27-07:00
[System]        FileAccessDate                  : 2021:08:07 09:31:06-07:00
[System]        FileCreateDate                  : 2021:06:09 14:40:49-07:00
[QuickTime]     CreateDate                      : 2021:05:05 11:47:14-07:00
[QuickTime]     ModifyDate                      : 2005:05:04 22:05:05-07:00
[Track1]        TrackCreateDate                 : 2002:02:01 18:02:02-08:00
[Track1]        TrackModifyDate                 : 2003:03:02 19:03:03-08:00
[Track1]        MediaCreateDate                 : 2000:05:04 22:05:05-07:00
[Track1]        MediaModifyDate                 : 2000:12:31 17:01:01-08:00
[Track2]        TrackCreateDate                 : 2002:02:01 18:02:02-08:00
[Track2]        TrackModifyDate                 : 2003:03:02 19:03:03-08:00
[Track2]        MediaCreateDate                 : 2000:05:04 22:05:05-07:00
[Track2]        MediaModifyDate                 : 2000:12:31 17:01:01-08:00
[ItemList]      ContentCreateDate               : 1990


Pick a tag name from the second column that holds the time you want to copy.  You can then copy that to the file system timestamps. For example, if the CreateDate (the most likely candidate) was correct, then you would use this command
exiftool -api QuickTimeUTC '-FileCreateDate<CreateDate' '-FileModifyDate<CreateDate' /path/to/files/

There is the possibility that the timestamps may be off by your timezone, especially if the video was taken by an older camera that didn't save timezone information.  In that case, try removing -api QuickTimeUTC from the command.
Title: Re: change file date
Post by: r2k on August 07, 2021, 03:16:45 PM
Hi,

this i tried with one test copy "1.mov"

ls -l 1.mov
-rw-r--r--@ 1 xxx  xxx  4017429  7 Aug 00:07 1.mov


timestamp is 7.Aug

exiftool 1.mov
ExifTool Version Number         : 12.26
File Name                       : 1.mov
Directory                       : .
File Size                       : 3.8 MiB
File Modification Date/Time     : 2021:08:07 00:07:41+02:00
File Access Date/Time           : 2021:08:07 00:07:41+02:00
File Inode Change Date/Time     : 2021:08:07 21:11:43+02:00
File Permissions                : -rw-r--r--
File Type                       : MOV
File Type Extension             : mov
MIME Type                       : video/quicktime
Major Brand                     : Apple QuickTime (.MOV/QT)
Minor Version                   : 0.0.0
Compatible Brands               : qt
Media Data Size                 : 4010537
Media Data Offset               : 36
Movie Header Version            : 0
Create Date                     : 2021:08:06 22:07:41


Real Create date is 6. Aug

now i typed
exiftool -api QuickTimeUTC '-FileCreateDate<CreateDate' '-FileModifyDate<CreateDate' 1.mov

unfortunately nothing changed the timestamp on file level

Your command not correct for just one file?
Title: Re: change file date
Post by: StarGeek on August 07, 2021, 03:27:26 PM
You are in a +02:00 time zone.  The CreateDate is in UTC, as per the spec.  See the fourth paragraph on the Quicktime tags page (https://exiftool.org/TagNames/QuickTime.html).  2021:08:06 22:07:41 +2 hours = 2021:08:07 00:07:41 local time.

My apologies, I meant to add the -api QuickTimeUTC option in my listed command so Exiftool will correctly adjust the output to the local time zone.  The example output shows the command correctly.

Your file is correctly set as it is.
Title: Re: change file date
Post by: r2k on August 07, 2021, 03:56:10 PM
ok sorry my fault.... the correct date seems to be 2. Aug 19:14



exiftool -api QuickTimeUTC -time:all -G1 -a -s 1.mov
[System]        FileModifyDate                  : 2021:08:07 00:07:41+02:00
[System]        FileAccessDate                  : 2021:08:07 21:48:25+02:00
[System]        FileInodeChangeDate             : 2021:08:07 21:11:43+02:00
[QuickTime]     CreateDate                      : 2021:08:07 00:07:41+02:00
[QuickTime]     ModifyDate                      : 2021:08:07 00:07:41+02:00
[Track1]        TrackCreateDate                 : 2021:08:07 00:07:41+02:00
[Track1]        TrackModifyDate                 : 2021:08:07 00:07:41+02:00
[Track1]        MediaCreateDate                 : 2021:08:07 00:07:41+02:00
[Track1]        MediaModifyDate                 : 2021:08:07 00:07:41+02:00
[Track2]        TrackCreateDate                 : 2021:08:07 00:07:41+02:00
[Track2]        TrackModifyDate                 : 2021:08:07 00:07:41+02:00
[Track2]        MediaCreateDate                 : 2021:08:07 00:07:41+02:00
[Track2]        MediaModifyDate                 : 2021:08:07 00:07:41+02:00
[Keys]          CreationDate                    : 2021:08:02 19:14:04+02:00
Title: Re: change file date
Post by: StarGeek on August 07, 2021, 04:04:30 PM
Ok, to set the file system time stamps to the CreationDate
exiftool '-FileCreateDate<CreationDate' '-FileModifyDate<CreationDate' 1.mov

The API option isn't needed for CreationDate as it's meant to be local time, not UTC.  So you can just directly copy it.

If you wanted to change the other time related tags listed there, you would want to include the -api QuickTimeUTC option.  Here I also use a wildcard to write both the create and modify dates for Track and Media time stamps at the same time.
exiftool -api QuickTimeUTC '-CreateDate<CreationDate' '-Track*Date<CreationDate' '-Media*Date<CreationDate' 1.mov
Title: Re: change file date
Post by: r2k on August 07, 2021, 04:11:31 PM
ls -l 1.mov
-rw-r--r--@ 1 xxx  xxx  4017429  7 Aug 00:07 1.mov

exiftool '-FileCreateDate<CreationDate' '-FileModifyDate<CreationDate' 1.mov
    1 image files updated

ls -l 1.mov
-rw-r--r--@ 1 xxx  xxx  4017429  2 Aug 19:14 1.mov


great that worked perfectly :-)

can i issue this commant for *.mov or do i need to invoke find command?
Title: Re: change file date
Post by: StarGeek on August 07, 2021, 04:20:15 PM
You don't want to use find, as that is Common Mistake #3 (https://exiftool.org/mistakes.html#M3).  You don't want to run exiftool once for every file, as exiftool's biggest performance hit is the startup time.

You can't use *.mov (see Common Mistake #2 (https://exiftool.org/mistakes.html#M2)).  Instead, you would use the -ext (-extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension) to limit the scope and -r (-recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse) to recurse into subdirectories.

If you want to process the current directory, you would use a dot . to indicate it.

Finally, while it doesn't affect this command, as it just sets the OS time stamps, any command that writes the embedded data, like the last command I put above, then exiftool will create backup files with _original added to the end.  You can suppress the creation of backup files by adding the -overwrite_original option (https://exiftool.org/exiftool_pod.html#overwrite_original).

This command will write all MOV files in the current directory and any sub-directories.
exiftool -ext mov -r '-FileCreateDate<CreationDate' '-FileModifyDate<CreationDate'  .
Title: Re: change file date
Post by: r2k on August 07, 2021, 04:31:00 PM
nice....  :) the last command was updating all my mov´s in less than 3 sec´s

thx a lot...
Title: Re: change file date
Post by: Dunlop on August 16, 2021, 04:19:16 AM
Thank you this helped a lot!  :D
Title: Re: change file date
Post by: drowelf on December 09, 2022, 12:29:07 AM
Ok, I've followed the information in this post, but I can not get the tool to change the File Modified Timestamps using the commands as listed. I've can successfully see that my .mp4 files have the Quicktime Create and Modified date as the time I want to set the file timestamps too.

V:\ToReview\2022-09-10 - S10>\exiftool -api QuickTimeUTC -time:all -G1 -a -s 20221101_124052.mp4
[System]        FileModifyDate                  : 2022:12:08 18:00:02-05:00
[System]        FileAccessDate                  : 2022:12:08 18:00:02-05:00
[System]        FileCreateDate                  : 2022:12:08 18:00:02-05:00
[QuickTime]    CreateDate                      : 2022:11:01 12:40:54-04:00
[QuickTime]    ModifyDate                      : 2022:11:01 12:40:54-04:00
[Track1]        TrackCreateDate                : 2022:11:01 12:40:54-04:00
[Track1]        TrackModifyDate                : 2022:11:01 12:40:54-04:00
[Track1]        MediaCreateDate                : 2022:11:01 12:40:54-04:00
[Track1]        MediaModifyDate                : 2022:11:01 12:40:54-04:00
[Track2]        TrackCreateDate                : 2022:11:01 12:40:54-04:00
[Track2]        TrackModifyDate                : 2022:11:01 12:40:54-04:00
[Track2]        MediaCreateDate                : 2022:11:01 12:40:54-04:00
[Track2]        MediaModifyDate                : 2022:11:01 12:40:54-04:00

But all variations of the command to set the timestamp return with the message "The system cannot find the file specified."

V:\ToReview\2022-09-10 - S10>\exiftool -ext mp4 '-FileCreateDate<CreateDate' '-FileModifyDate<CreateDate'  .
The system cannot find the file specified.

or this

V:\ToReview\2022-09-10 - S10>\exiftool -ext mp4 '-FileCreateDate<CreateDate' '-FileModifyDate<CreateDate'  20221101_124052.mp4
The system cannot find the file specified.

or

V:\ToReview\2022-09-10 - S10>\exiftool -api QuickTimeUTC '-FileCreateDate<CreateDate' '-FileModifyDate<CreateDate'        20221101_191513.mp4
The system cannot find the file specified.
Title: Re: change file date
Post by: Phil Harvey on December 09, 2022, 07:00:00 AM
The system cannot find "\exiftool".  Try "exiftool" instead, or drag and drop exiftool onto the command window.  Also, are you running in a Windows CMD shell now?  If so you need to use double quotes (") instead of single quotes (') in your command.

- Phil
Title: Re: change file date
Post by: StarGeek on December 09, 2022, 11:07:49 AM
If you're using Windows CMD, you need to change the single quotes into double quotes.  CMD will return The system cannot find the file specified. when you use single quotes.

Try
\exiftool -ext mp4 "-FileCreateDate<CreateDate" "-FileModifyDate<CreateDate" .
Title: Re: change file date
Post by: drowelf on December 10, 2022, 07:56:12 PM
Quote from: Phil Harvey on December 09, 2022, 07:00:00 AMThe system cannot find "\exiftool".  Try "exiftool" instead, or drag and drop exiftool onto the command window.  Also, are you running in a Windows CMD shell now?  If so you need to use double quotes (") instead of single quotes (') in your command.

- Phil

Yes, this is on a windows system, so it was the single versus double quotes. You learn something new everyday!

the \exiftool was correct, as I keep all my commandline photo tools in the root directory of the share that is my photo/video repository.

Thanks for the quick answer. Now I have all those pesky .mp4s that got their dates mangled after a stop over on Google Cloud.