I'd like this to return true — if a tag doesn't exist OR if the value of the tag is not 'myname'.
See below for what I have. But I'm getting a false even if tag XMP-cc:AttributionName does not exist.
exiftool \
-r \
-if 'not $XMP-cc:AttributionName =~ /myname/' \
-FileName \
.
Thanks!
Try
-if 'not $XMP-cc:AttributionName =~ /myname/ or not defined $XMP-cc:AttributionName'
Quote from: StarGeek on March 25, 2017, 06:36:32 PM
-if 'not $XMP-cc:AttributionName =~ /myname/ or not defined $XMP-cc:AttributionName'
I would recommend reversing the order since the =~ may fail if the tag is not defined:
-if 'not defined $XMP-cc:AttributionName or not $XMP-cc:AttributionName =~ /myname/'- Phil
Big thanks Phil & StarGeek! I was not aware that OR could be used. Somehow I missed to find it on the documentation. And the order turned out to be relevant as well! Thanks again! :)
Quote from: Phil Harvey on March 25, 2017, 10:19:24 PM
I would recommend reversing the order since the =~ may fail if the tag is not defined:
-if 'not defined $XMP-cc:AttributionName or not $XMP-cc:AttributionName =~ /myname/'
And while you're at it, change
not $XMP-cc:AttributionName =~ /myname/ into
$XMP-cc:AttributionName !~ /myname/ :)
-if 'not defined $XMP-cc:AttributionName or $XMP-cc:AttributionName !~ /myname/'