How to use -if to compare two tags, when one tag is empty?

Started by mlaverdiere, January 20, 2019, 12:18:13 PM

Previous topic - Next topic

mlaverdiere

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.

StarGeek

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'
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mlaverdiere

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!).




StarGeek

Try
-if '$XMP-dc:Creator ne $xmp-acdsee:Author or not (defined $XMP-dc:Creator and defined $xmp-acdsee:Author)'
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mlaverdiere

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.

Phil Harvey

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