Author Topic: How to use -if to compare two tags, when one tag is empty?  (Read 260 times)

mlaverdiere

  • Jr. Member
  • **
  • Posts: 18
How to use -if to compare two tags, when one tag is empty?
« 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.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: How to use -if to compare two tags, when one tag is empty?
« Reply #1 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'
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

mlaverdiere

  • Jr. Member
  • **
  • Posts: 18
Re: How to use -if to compare two tags, when one tag is empty?
« Reply #2 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!).




StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: How to use -if to compare two tags, when one tag is empty?
« Reply #3 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)'
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

mlaverdiere

  • Jr. Member
  • **
  • Posts: 18
Re: How to use -if to compare two tags, when one tag is empty?
« Reply #4 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.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).