ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Tania on September 23, 2014, 07:17:52 PM

Title: Is it possible to use "OR" in "IF" statement?
Post by: Tania on September 23, 2014, 07:17:52 PM
Hello everyone! I want to check Caption-Abstract tag for several words. if either of them is present, I do some actions. Is it possible to do so? Right now I just check for each of the word in a new exiftool operation, but obviously it takes more time, because the file is scanned two times instead of one:
-if '$Caption-Abstract =~ /word1/i' ....
-if '$Caption-Abstract =~ /word2/i' ....
Title: Re: Is it possible to use "OR" in "IF" statement?
Post by: StarGeek on September 23, 2014, 08:47:49 PM
Try
-if '$Caption-Abstract =~ /word1|word2/i'

The part between the slashes is a Regular Expression and the bar is used for alternative options.  Check out this website (http://www.regular-expressions.info/alternation.html) for more info.
Title: Re: Is it possible to use "OR" in "IF" statement?
Post by: Tania on September 23, 2014, 09:13:15 PM
Thanks so much! That was exactly something I've been looking for;)