if condition with or

Started by mitkofr, June 12, 2020, 04:21:42 PM

Previous topic - Next topic

mitkofr

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)

Phil Harvey

Try this:

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

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

- Pil
...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 ($).

mitkofr

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?

StarGeek

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?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

greybeard

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)'