Linux: If MediaCreateDate is missing, then....

Started by sdfvad3, September 23, 2023, 02:30:28 AM

Previous topic - Next topic

sdfvad3

When using gphotos-sync to download google photos, the google API sets all MP4 files with a media created date of 00:00:00 which appears as 12/31/1969.

I figured out how to populate the MediaCreateDate field with the FileModifyDate, which solves the problem, but I want to make an If statement that only populates the MediaCreateDate if it is missing, so I am not overwriting thousands of files all the time.

This is what I came up with, which does not work.

exiftool -api QuickTimeUTC -if '-quicktime:MediaCreateDate lt $FileModifyDate' '-alldates<FileModifyDate' -ext .mp4 /home/user/dir -r -P -overwrite_original -api LargeFileSupport

Any help?

StarGeek

You need a dollar sign $ instead of a hyphen - in the -if option.

exiftool -api QuickTimeUTC -if '$quicktime:MediaCreateDate lt $FileModifyDate' '-alldates<FileModifyDate' -ext .mp4 /home/user/dir -r -P -overwrite_original -api LargeFileSupport
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

sdfvad3

Quote from: StarGeek on September 23, 2023, 12:18:56 PMYou need a dollar sign $ instead of a hyphen - in the -if option.

exiftool -api QuickTimeUTC -if '$quicktime:MediaCreateDate lt $FileModifyDate' '-alldates<FileModifyDate' -ext .mp4 /home/user/dir -r -P -overwrite_original -api LargeFileSupport

This query still does not work. The query runs, but the result is not correct.

Perhaps to make this more simple, how would the if statement be written MediaCreateDate is null or earlier than January 1, 1970?

StarGeek

Ah, it works, but you are only writing to AllDates. If exiftool says
1 image files updatedthen it did write something.  It just didn't write what you thought you were writing.

The AllDates shortcut tag only includes the CreateDate, DateTimeOriginal, and ModifyDate tags (see the Shortcuts tags page), not any of the Media*Date or Track*Date tags.

Use this to write to all the track time stamps as well
exiftool -api QuickTimeUTC -if '$quicktime:MediaCreateDate lt $FileModifyDate' '-alldates<FileModifyDate' '-Media*Date<FileModifyDate' '-Track*Date<FileModifyDate' -ext .mp4 /home/user/dir -r -P -overwrite_original -api LargeFileSupport
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).