ExifTool Forum

ExifTool => Newbies => Topic started by: sgraystar on April 19, 2019, 07:24:21 PM

Title: Difficulty using IF statement on tif files
Post by: sgraystar 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:


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?


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.
Title: Re: Difficulty using IF statement on tif files
Post by: StarGeek 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 (https://exiftool.org/exiftool_pod.html#php) 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.
Title: Re: Difficulty using IF statement on tif files
Post by: sgraystar 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'" .

Title: Re: Difficulty using IF statement on tif files
Post by: StarGeek on April 19, 2019, 10:53:40 PM
Quote from: sgraystar on April 19, 2019, 09:58:11 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.
Title: Re: Difficulty using IF statement on tif files
Post by: jammer 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.
Title: Re: Difficulty using IF statement on tif files
Post by: StarGeek on April 23, 2019, 06:11:20 PM
Quote from: jammer on April 23, 2019, 04:27:12 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 (https://exiftool.org/forum/index.php/topic,8137.msg41663.html#msg41663) for more details.
Title: Re: Difficulty using IF statement on tif files
Post by: sgraystar on April 23, 2019, 07:21:32 PM
Wow! Thanks for the tip.