nextcloud if created File newer then DateTimeOriginal

Started by badsmoke, August 30, 2021, 07:56:43 AM

Previous topic - Next topic

badsmoke

Hello

I am currently trying to write a script that adapts all my images in the nextcloud, which is working wonderfully so far.

But I would like to have a condition that it only adjusts the files if "FileModifyDateTime" is "younger" than "datetimeoriginal".

the script looks like this so far:



#!/bin/bash


PHOTOS_FOLDER=$1



#check if have all files Date/Time Original, if not, use create Date/Time
exiftool -overwrite_original -r '-datetimeoriginal<createdate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq ("JPEG" or "MP4")) and ($createdate)' "${PHOTOS_FOLDER}"

#check if have all files Date/Time Original, if not, use gps Date/Time
exiftool -overwrite_original -r '-datetimeoriginal<gpsdatetime' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq ("JPEG" or "MP4")) and ($gpsdatetime)' "${PHOTOS_FOLDER}"


#change modifydate to Date/Time Original
exiftool -ee -overwrite_original -r '-FileModifyDate<datetimeoriginal' -if '(not $FileModifyDate eq $datetimeoriginal)' "${PHOTOS_FOLDER}"



I have already tried gt/lt/eq but I think the two formats do not get along with each other because of the "+2:00".


File Modification Date/Time     : 2021:07:31 17:21:07+02:00
Date/Time Original              : 2021:07:31 17:21:07



i want to prevent it from touching every file every time i run


exiftool -ee -r '-FileModifyDate<datetimeoriginal' "${PHOTOS_FOLDER}"



thanks for the help

StarGeek

You can use the -d (-dateFormat) option to remove the timezone part
C:\>exiftool -G1 -a -s -FileModifyDate -d "%Y:%m:%d %H:%M:%S" y:\!temp\Test4.jpg
[System]        FileModifyDate                  : 2020:08:21 12:00:00


Or if you're already using the -d option for something else, you can use the DateFmt helper function.
-if '${FileModifyDate#;DateFmt("%Y:%m:%d %H:%M:%S")} ge $DateTimeOriginal'
* 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).