ExifTool Forum

ExifTool => Newbies => Topic started by: mlaverdiere on January 20, 2019, 12:18:13 PM

Title: How to use -if to compare two tags, when one tag is empty?
Post by: mlaverdiere on January 20, 2019, 12:18:13 PM
Hi,

I have this command in a bash script:

exiftool -P -p '$directory/$filename' -srcfile %d%f.%e -@ sourcefile.txt -if '$XMP-dc:Creator ne $xmp-acdsee:Author' > list.txt

It works fine as long as XMP-dc:Creator is not empty. In that case, if it is not equivalent to xmp-acdsee:Author, then the file will be listed in list.txt

My problem is when XMP-dc:Creator is empty. Even if it is not equivalent to  xmp-acdsee:Author, it seems that the file will not be listed in list.txt

What would the solution/workaround to deal with empty tags?

Thanks.
Title: Re: How to use -if to compare two tags, when one tag is empty?
Post by: StarGeek on January 20, 2019, 01:45:19 PM
I'm assuming Mac/Linux?

The -if :$XMP-dc:Creator ne $xmp-acdsee:Author" works correctly here on Windows, but I recall a similar difference a long time ago but having to do with undefined numbers.

Try -if '$XMP-dc:Creator ne $xmp-acdsee:Author or not defined $XMP-dc:Creator'
Title: Re: How to use -if to compare two tags, when one tag is empty?
Post by: mlaverdiere on January 20, 2019, 02:16:30 PM
Thanks for the follow-up

Yes, I'm on Linux.

Following your suggestion, I assume that if XMP-dc:Creator is empty (not defined), the condition will be met and then the file will be listed in list.txt?

Actually, if  XMP-dc:Creator is empty (not defined), I would like that the file be listed in list.txt only if xmp-acdsee:Author is also empty (not defined).

Could I use some combinaison of or/and (I looked to find some info on using or/and but found nothing... Though terms to search since these are so common words!).



Title: Re: How to use -if to compare two tags, when one tag is empty?
Post by: StarGeek on January 20, 2019, 04:09:53 PM
Try
-if '$XMP-dc:Creator ne $xmp-acdsee:Author or not (defined $XMP-dc:Creator and defined $xmp-acdsee:Author)'
Title: Re: How to use -if to compare two tags, when one tag is empty?
Post by: mlaverdiere on January 21, 2019, 06:54:30 AM
OK, I'll try it.

Could you point me where I could find the documentation on how to use operators and/or with -if?

Thanks again.
Title: Re: How to use -if to compare two tags, when one tag is empty?
Post by: Phil Harvey on January 21, 2019, 07:05:44 AM
Here is the ExifTool -if option documentation (https://exiftool.org/exiftool_pod.html#if-NUM-EXPR), and here is the Perl operator documentation (https://perldoc.perl.org/perlop.html).

- Phil