Brackets for multiple IFs

Started by Birdman, March 09, 2023, 08:50:37 AM

Previous topic - Next topic

Birdman

Hello,

is there a way to use something like brackets for more complex IF commands? I know of "and", "or", but how can those be combined for complex commands? For example:
-if "$var1 eq '1' and $var2 eq '2' or $var3 eq '3'"
With brackets this could be meant as
-if "$var1 eq '1' and ($var2 eq '2' or $var3 eq '3')"or
-if "($var1 eq '1' and $var2 eq '2') or $var3 eq '3'"
Best regards,

Martin (Birdman)

StarGeek

Your examples show the correct way to set precedence.  Exiftool is written in Perl, so you can look at any Perl tutorial on its operators.
"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

Phil Harvey

From the perlop man page:

       Perl operators have the following associativity and precedence, listed
       from highest precedence to lowest.  Operators borrowed from C keep the
       same precedence relationship with each other, even where C's precedence
       is slightly screwy.  (This makes learning Perl easier for C folks.)
       With very few exceptions, these all operate on scalar values only, not
       array values.

           left        terms and list operators (leftward)
           left        ->
           nonassoc    ++ --
           right       **
           right       ! ~ \ and unary + and -
           left        =~ !~
           left        * / % x
           left        + - .
           left        << >>
           nonassoc    named unary operators
           nonassoc    < > <= >= lt gt le ge
           nonassoc    == != <=> eq ne cmp ~~
           left        &
           left        | ^
           left        &&
           left        || //
           nonassoc    ..  ...
           right       ?:
           right       = += -= *= etc. goto last next redo dump
           left        , =>
           nonassoc    list operators (rightward)
           right       not
           left        and
           left        or xor


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