if... if... else

Started by gambling, Today at 04:28:37 AM

Previous topic - Next topic

gambling

Hello friends of exiftool.

I need a command with two "if" and the "else" statement.

First IF:
If DateTimeOriginal exists, i want to copy/write it to all other possible dates

Second IF:
If DateTimeOriginal does not exist, but if CreateDate exists, i want to copy/write it to all other possible dates

Else:
If both (DateTimeOriginal and CreateDate) do not exist (meaning both if conditoins do not match), I want to try to read the filename and copy/write the date to all other possible dates


Can i use this one?:
exiftool -r -P
-if "$DateTimeOriginal" "-AllDates<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal" "-FileCreateDate<DateTimeOriginal" -execute
-if "$CreateDate" "-AllDates<CreateDate" "-FileModifyDate<CreateDate" "-FileCreateDate<CreateDate" -execute
"-AllDates<$Filename 00:00:00" "-FileModifyDate<$Filename 00:00:00" "-FileCreateDate<$Filename 00:00:00"
/path/to/files/


Thank you very much for you help !!  :)

Phil Harvey

You don't need to use -if here.  Just do this:

exiftool "-alldates<$filename 00:00:00" "-alldates<createdate" "-alldates<datetimeoriginal" DIR

The rightmost valid argument on the command line takes precedence.

But note that AllDates represents only the 3 common EXIF date/time tags: CreateDate, ModifyDate and DateTimeOriginal, so only these tags will get written.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gambling

thank you very much !! That worked  8)  :)