ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: mitkofr on June 12, 2020, 04:21:42 PM

Title: if condition with or
Post by: mitkofr on June 12, 2020, 04:21:42 PM
Hi,

I want to apply the following logic:
-if '$createdate eq $datetimeoriginal or $createdate or $datetimeoriginal'

so do something but only if the dates don't differ unless only one is defined.
($createdate alone is fine, same for $datetimeoriginal but if both are defined they must be the same)
Title: Re: if condition with or
Post by: Phil Harvey on June 12, 2020, 05:25:26 PM
Try this:

-if '$createdate and $datetimeoriginal and $createdate ne $datetimeoriginal'

This will do something only if both dates exist and are different.

- Pil
Title: Re: if condition with or
Post by: mitkofr on June 12, 2020, 06:58:16 PM
Yes, -if 'not ($createdate and $datetimeoriginal and $createdate ne $datetimeoriginal)' does what I want but
what was wrong with my code? Is or not supported?
Title: Re: if condition with or
Post by: StarGeek on June 12, 2020, 08:01:53 PM
Your example only works if both CreateDate and DateTimeOriginal don't exist, which is different that what you said in your first post. 

Did you try the version Phil listed?
Title: Re: if condition with or
Post by: greybeard on June 13, 2020, 09:46:37 AM
Quote from: StarGeek on June 12, 2020, 08:01:53 PM
Your example only works if both CreateDate and DateTimeOriginal don't exist, which is different that what you said in your first post. 

Did you try the version Phil listed?

If you want use "or" then one of the following will work - depending on what you want to happen if neither field exists:

-if '$createdate eq $datetimeoriginal or !($createdate) or !($datetimeoriginal)'

-if '($createdate eq $datetimeoriginal or !($createdate) or !($datetimeoriginal)) and ($createdate or $datetimeoriginal)'