Author Topic: Difficulty using IF statement on tif files  (Read 237 times)

sgraystar

  • Newbie
  • *
  • Posts: 4
Difficulty using IF statement on tif files
« on: April 19, 2019, 07:24:21 PM »
Hi,

I have scanned TIFF images from a few different scanners so  I thought it would be a simple task to sort them using using the -if '$make eq "Canon"' example, however the IF statement is not working as I expected.

To confirm the make and model metadata are visible in the files:

Code: [Select]
PS C:\Users\Public\Pictures\Scans3> exiftool -make -model .
======== ./scan_0530.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0531.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0532.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0533.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0534.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0535.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0536.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0537.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0538.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0539.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0540.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0541.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0542.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0543.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0544.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0545.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0546.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0547.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0548.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0549.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0550.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0551.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0552.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0553.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0554.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0555.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0556.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0557.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0558.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0559.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0560.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0561.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0562.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0563.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0564.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0565.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0566.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0567.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0568.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0569.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0570.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0571.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
======== ./scan_0572.tif
Make                            : EPSON
Camera Model Name               : Perfection V800/V850
    1 directories scanned
   43 image files read
PS C:\Users\Public\Pictures\Scans3>

With the output above, why would the following exiftool command fail?

Code: [Select]
PS C:\Users\Public\Pictures\Scans3> exiftool -model -if '$make eq "EPSON"' .
    1 directories scanned
   43 files failed condition
    0 image files read
PS C:\Users\Public\Pictures\Scans3>

Thanks in advance.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2516
Re: Difficulty using IF statement on tif files
« Reply #1 on: April 19, 2019, 07:55:32 PM »
There may be some other characters in the tag.  Maybe some trailing spaces, for example.

Try adding the -php option or something similar to the command.  The -php option will add quotes around the whole thing as well as escape other characters so you could actually see what is there.

If that doesn't help, I'd suggest switching to -if "$Make=~/EPSON/" to see if that helps.
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.

sgraystar

  • Newbie
  • *
  • Posts: 4
Re: Difficulty using IF statement on tif files
« Reply #2 on: April 19, 2019, 09:58:11 PM »
Thanks StarGeek

No luck with the suggestions, but sent me in the right direction, swapping the single and double quotes in the command line did the trick (Windows 10 cmd.exe), now to read up why ...

exiftool -model -if "$make eq 'EPSON'" .


Powershell required escaping of the $

exiftool -model -if "`$make eq 'EPSON'" .


StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2516
Re: Difficulty using IF statement on tif files
« Reply #3 on: April 19, 2019, 10:53:40 PM »
Powershell required escaping of the $

exiftool -model -if "`$make eq 'EPSON'" .

Probably along the same lines as with linux/Mac shell, double quotes lead to interpreting $Make as a shell variable instead of an exiftool one.

Also be aware that Powershell will corrupt binary output if you want to redirect or pipe binary data from exiftool.  The most common problem is trying to extract thumbnail or preview images.  You will have to use CMD in those situations.
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.

jammer

  • Newbie
  • *
  • Posts: 9
Re: Difficulty using IF statement on tif files
« Reply #4 on: April 23, 2019, 04:27:12 PM »
Is binary pipe bug present in both "Windows Powershell" and "Powershell Core" ?
Thank you for your time.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2516
Re: Difficulty using IF statement on tif files
« Reply #5 on: April 23, 2019, 06:11:20 PM »
Is binary pipe bug present in both "Windows Powershell" and "Powershell Core" ?

I have no idea what Powershell core is, so I can't comment on that.

Check the links in this post for more details.
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.

sgraystar

  • Newbie
  • *
  • Posts: 4
Re: Difficulty using IF statement on tif files
« Reply #6 on: April 23, 2019, 07:21:32 PM »
Wow! Thanks for the tip.