Hi all,
Most grateful for any help you could provide. I know there are several threads for how to set DateTimeOriginal from directory name but I didn't see any that matched my issue, apologies if I inadvertently missed it. I'm pretty terrible with scripting regrettably. It's on my to-do list for the year.
I am sorting out photos and videos for the wife and I have run into a problem with ~1800 videos. I don't know how I did it, but back in 2018 I did something that changed all the DateTimeOriginal on these videos to the same day, when in fact they span years. However, all is not lost with the naming because the affected videos happen to be in directories based on location and date. I don't know if it was Photo Library or my NAS that did this, but I digress. It seems only .m4v files were affected, interestingly.
My problem is that the directory name is not your standard YYYY-MM-DD or something, but rather is like "March 5, 2015" or might contain a location too like "Anytown, NY - Crescent St, July 13, 2014" And there are a lot of these directories. What I want to do is run this recursively from the root directory to fix the .m4v files within each subdirectory that is affected. Now, not every directory has a date, and the ones that don't are fine. So I need to ensure that if the subdirectory does not have a date, it is skipped.
I have attached a picture of an example to illustrate the issue.
What I want to do:
Multimedia/March 5, 2015/IMG_3882.M4V --> (exiftool process) --> DateTimeOriginal 2018-08-12 --> 2015-03-05 based on name of directory
Multimedia/DCIM2/IMG_3002.M4V --> skipped, as there is no date
The hard part for me is how to parse the date properly, from Month D, Yr to YYYY-MM-DD.. and then since I don't have the time in the directory name I don't want to change the time taken. Or, alternatively I can set them all to a specific time, that won't be a problem so long as the date is right.
I tried for a number of hours yesterday on this and I'm just spinning my wheels. If it matters for syntax purposes I am running exiftool on macOS Catalina 10.15.4. I really appreciate any help! Thanks
You may still have the date in another tag.
What do you see with
exiftool PutTheNameOfTheFileHere -a -G -*date*
Good call, I see Content Create Date is accurate. But the rest of the fields are not. So, maybe there is a way to copy Content Create Date to Media Create Date? I'm taking a stab that's what needs to happen. BTW, the -*date* syntax would not work for me, using a Mac if that makes a difference.
# exiftool IMG_3535.m4v -a -G | grep Date
[File] File Modification Date/Time : 2018:08:11 21:22:28-04:00
[File] File Access Date/Time : 2020:05:05 11:27:18-04:00
[File] File Inode Change Date/Time : 2020:05:05 11:27:20-04:00
[QuickTime] Create Date : 2018:08:12 01:22:05
[QuickTime] Modify Date : 2018:08:12 01:22:25
[QuickTime] Track Create Date : 2018:08:12 01:22:05
[QuickTime] Track Modify Date : 2018:08:12 01:22:25
[QuickTime] Media Create Date : 2018:08:12 01:22:05
[QuickTime] Media Modify Date : 2018:08:12 01:22:25
[QuickTime] Track Create Date : 2018:08:12 01:22:05
[QuickTime] Track Modify Date : 2018:08:12 01:22:25
[QuickTime] Media Create Date : 2018:08:12 01:22:05
[QuickTime] Media Modify Date : 2018:08:12 01:22:25
[QuickTime] Content Create Date : 2013:04:29 17:42:10-04:00 <---- Correct
[QuickTime] Content Create Date : 2013:04:29 17:42:10-04:00 <---- Correct
On Mac/Linux you must quote arguments containing wildcards.
To copy ContentCreateDate to other date/time tags, you can do something like this:
exiftool "-mediacreatedate<contentcreatedate" "-mediamodifydate<contentcreatedate" ... FILE
- Phil
Quote from: Phil Harvey on May 05, 2020, 11:41:51 AM
On Mac/Linux you must quote arguments containing wildcards.
- Phil
Strange. I didn't on my mac.
cellini:2013-03 alan$ exiftool dove_0034.m4v -a -G -*date*
[File] File Modification Date/Time : 2013:03:28 14:04:09+00:00
[File] File Access Date/Time : 2020:05:05 16:43:22+01:00
[File] File Inode Change Date/Time : 2019:01:12 15:16:58+00:00
[QuickTime] Create Date : 2013:03:28 13:54:05
[QuickTime] Modify Date : 2013:03:28 13:54:05
[QuickTime] Track Create Date : 2013:03:28 13:54:02
[QuickTime] Track Modify Date : 2013:03:28 13:54:05
[QuickTime] Media Create Date : 2013:03:28 13:54:05
[QuickTime] Media Modify Date : 2013:03:28 13:54:05
cellini:2013-03 alan$
Edit: probably the shell. It doesn't work with zsh.
Another thing to point out is that DateTimeOriginal is almost certainly not the tag you want to use for videos. As far as I've been able to tell, it's rarely used and if you use Apple Photos, it will cause that app to show the wrong date. The Quicktime:Createdate is the best place to hold the time stamp.
Also read the fourth paragraph on the Quicktime tag page (https://exiftool.org/TagNames/QuickTime.html) with regards to how the time is stored and problems with it.
Yep I am on zsh so that explains why quotes were not needed for you, but are for me.
"Another thing to point out is that DateTimeOriginal is almost certainly not the tag you want to use for videos." Right you are, I was guessing at using that based on other threads about how to rename pictures. I was heretofore oblivious how different these tags are handled on the two.
Ok so, I think I have a game plan. copy QuickTime:Content Create Date to QuickTime: Create Date, and then run recursively for all m4v files. Just need to finalize my syntax to do that, but looks simple enough. Thanks!
UPDATE: Confirmed this solved issue:
% exiftool IMG_3535.m4v -a -G "-*Date*"
[File] File Modification Date/Time : 2020:05:05 12:10:07-04:00
[File] File Access Date/Time : 2020:05:05 12:10:08-04:00
[File] File Inode Change Date/Time : 2020:05:05 12:10:07-04:00
[QuickTime] Create Date : 2018:08:12 01:22:05
[QuickTime] Modify Date : 2018:08:12 01:22:25
[QuickTime] Track Create Date : 2018:08:12 01:22:05
[QuickTime] Track Modify Date : 2018:08:12 01:22:25
[QuickTime] Media Create Date : 2013:04:29 17:42:10 <--- Updated
[QuickTime] Media Modify Date : 2013:04:29 17:42:10 <--- Updated
[QuickTime] Track Create Date : 2018:08:12 01:22:05
[QuickTime] Track Modify Date : 2018:08:12 01:22:25
[QuickTime] Media Create Date : 2013:04:29 17:42:10
[QuickTime] Media Modify Date : 2013:04:29 17:42:10
[QuickTime] Content Create Date : 2013:04:29 17:42:10-04:00
[QuickTime] Content Create Date : 2013:04:29 17:42:10-04:00
ExifTool will not overwrite existing files.
The first message:
Error: 'Multimedia/IMG_2173.m4v' already exists - Multimedia/exported/IMG_2173.m4v
indicates that 'Multimedia/IMG_2173.m4v' already exists.
- Phil
Thanks Phil,
I realized what was going on about 30 seconds after I posted that and it was like a light switch. I have duplicates. So the original video file actually exists on the day it is supposed to, and then I have a copy of some 1800 videos that I don't need. And the fact they were exported may explain why the create date is wrong in the first place. I have like 80k media files I'm combing through and I had used a program to dedup the photos and I didn't realize it wasn't comparing videos.
Phil, sorry to bother you but I am not really understanding this error. I thought at first I had this but when I'm hitting that error I'm realizing it's not fixing the files.
I am changing exif info on existing files. I thought at first I was hitting this error because I had duplicate files but that's no longer the case - I've cleared those out. And now, I'm hitting the error on pretty much every single one when I do max verbosity. So, does changing that exif data amount to overwriting? And if so, how do I go about getting around this error?
The command I am running:
% exiftool -r -directory=Multimedia -i exported -ext m4v "-mediacreatedate<contentcreatedate" "-mediamodifydate<contentcreatedate" * -v5
Output snippet:
======== Multimedia/December 8, 2016/IMG_8516.m4v
Setting new values from Multimedia/December 8, 2016/IMG_8516.m4v
Writing Track#:MediaCreateDate if tag exists
Writing Track#:MediaModifyDate if tag exists
Error: 'Multimedia/IMG_8516.m4v' already exists - Multimedia/December 8, 2016/IMG_8516.m4v
Exifdata showing the value was not changed:
% exiftool -a -G "-*date*" IMG_8516.m4v
[File] File Modification Date/Time : 2018:08:11 19:19:16-04:00
[File] File Access Date/Time : 2020:05:05 22:00:11-04:00
[File] File Inode Change Date/Time : 2018:08:11 19:19:16-04:00
[QuickTime] Create Date : 2018:08:11 23:19:14 <-- NOT CHANGED
[QuickTime] Modify Date : 2018:08:11 23:19:16
[QuickTime] Track Create Date : 2018:08:11 23:19:14
[QuickTime] Track Modify Date : 2018:08:11 23:19:16
[QuickTime] Media Create Date : 2018:08:11 23:19:14
[QuickTime] Media Modify Date : 2018:08:11 23:19:16
[QuickTime] Track Create Date : 2018:08:11 23:19:14
[QuickTime] Track Modify Date : 2018:08:11 23:19:16
[QuickTime] Media Create Date : 2018:08:11 23:19:14
[QuickTime] Media Modify Date : 2018:08:11 23:19:16
[QuickTime] Content Create Date : 2016:12:08 18:55:59-05:00 <--- CORRECT DATE
And the weirdest of all, is that exiftool actually seems to create a duplicate of the file.
Multimedia % stat IMG_8516.m4v
905969688 11666521464616301410 -rwx------ 1 <user> staff 0 21980270 "May 5 22:52:16 2020" "May 5 22:52:10 2020" "May 5 22:52:10 2020" "May 5 22:52:04 2020" 1024 42932 0 IMG_8516.m4v
Multimedia % stat "December 8, 2016/IMG_8516.m4v"
905969688 7292559987363759683 -rwx------ 1 <user> staff 0 21980270 "May 5 22:00:11 2020" "Aug 11 19:19:16 2018" "Aug 11 19:19:16 2018" "Aug 11 19:19:16 2018" 1024 42932 0x10000 December 8, 2016/IMG_8516.m4v
And that duplicate did not exist before running the command.
Phil just gave you a starting point, not the complete command (note the ...)
Add
'-Quicktime:CreateDate<contentcreatedate'
to the command to get it to set the CreateDate equal to the ContentCreatedate
Also, the command you listed didn't change anything because a file with that name already exists in the Multimedia directory. The copy in the December 8, 2016 directory must have already existed as well, because the command you list wouldn't move it to another completely different directory than what the command tells it to.
Thanks StarGeek. That was part of it, I was too quick to the mark and didn't realize the tags still needed adjusting. The other part was my syntax. I really and truly did not have any duplicates. And then I ran the command from the last post, and afterwards I had 16 duplicates, and they were the exact files that I had logs for from exiftool. But I was telling it to run it on all files in the wrong way with the *.
I'm going to leave my mistake so others can learn from it.
exiftool -r -v3 -ext m4v "-mediacreatedate<contentcreatedate" "-mediamodifydate<contentcreatedate" "-Quicktime:CreateDate<contentcreatedate" Multimedia
The final version of my command is above. And it's looking much better.
======== Multimedia/October 31, 2012//10.31.12..m4v
Setting new values from Multimedia/October 31, 2012//10.31.12..m4v
Writing Track#:MediaCreateDate if tag exists
Writing Track#:MediaCreateDate if tag exists
Writing Track#:MediaModifyDate if tag exists
Writing Track#:MediaModifyDate if tag exists
Writing QuickTime:CreateDate if tag exists
Writing QuickTime:CreateDate if tag exists
Rewriting Multimedia/October 31, 2012/10.31.12..m4v...
FileType = MP4
FileTypeExtension = MP4
MIMEType = video/mp4
Editing tags in: ItemList MOV Meta Movie QuickTime Track# UserData
Creating tags in:
Rewriting Movie
Rewriting MovieHeader
- MovieHeader:CreateDate = '3616860334'
+ MovieHeader:CreateDate = '3434543116'
Rewriting Track
Rewriting TrackHeader
Rewriting Media
Rewriting MediaHeader
- MediaHeader:MediaCreateDate = '3434543116'
+ MediaHeader:MediaCreateDate = '3434543116'
- MediaHeader:MediaModifyDate = '3434543116'
+ MediaHeader:MediaModifyDate = '3434543116'
Rewriting MediaInfo
Rewriting DataInfo
Rewriting DataRef
Rewriting SampleTable
Rewriting Track
Rewriting TrackHeader
Rewriting Media
Rewriting MediaHeader
- MediaHeader:MediaCreateDate = '3434543116'
+ MediaHeader:MediaCreateDate = '3434543116'
- MediaHeader:MediaModifyDate = '3434543116'
+ MediaHeader:MediaModifyDate = '3434543116'
Rewriting MediaInfo
Rewriting DataInfo
Rewriting DataRef
Rewriting SampleTable
Rewriting UserData
Rewriting Meta
Rewriting ItemList