Main Menu

Help with -if syntax

Started by mblanchette, May 09, 2019, 11:49:52 AM

Previous topic - Next topic

mblanchette

Hello,

I am trying to use exiftool to identify Pentax Pixel Shift images, but I have not been able to make it work.

I started by running:
exiftool -PixelShiftResolution -Quality -csv *.pef
, to make sure that I have files to process, but ran into trouble when I got to the -if logic.  I have tried all below, without success.  Can someone tell me what I am doing wrong?  Thanks!

exiftool -PixelShiftResolution -Quality -if "$PixelShiftResolution == 1" *.pef
exiftool -PixelShiftResolution -Quality -if "$PixelShiftResolution == On" *.pef
exiftool -PixelShiftResolution -Quality -if "$PixelShiftResolution eq On" *.pef
exiftool -PixelShiftResolution -Quality -if "$PixelShiftResolution eq 1" *.pef
exiftool -PixelShiftResolution -Quality -if "$PixelShiftResolution = 1" -csv *.pef
exiftool -PixelShiftResolution -Quality -if "$PixelShiftResolution = On" -csv *.pef
exiftool -Name -if $PixelShiftResolution="On" -csv *
exiftool -Name -if $PixelShiftResolution="On" -csv .
exiftool -Name -if '$PixelShiftResolution = 1' -csv *
exiftool -Name -if '$PixelShiftResolution == 1' -csv *
exiftool -Name -if '$PixelShiftResolution' -csv *
exiftool -Name -if '$PixelShiftResolution eq "On"' -csv *
exiftool -Name -if '$PixelShiftResolution = "On"' -csv *
exiftool -Name -if '$PixelShiftResolution == "On"' -csv *
exiftool -Name -if '$PixelShiftResolution == 1' -csv *
exiftool -Name -if '$PixelShiftResolution = 1' -csv *
exiftool -Name -if '$PixelShiftResolution eq 1' -csv *
exiftool -Name -if '$Quality ge 7' -csv *
exiftool -Name -if "$Quality ge 7" -csv *
exiftool -Name -if "$Quality = 7" -csv *
eexiftool -PixelShiftResolution -Quality -if "$Quality eq 7" -csv *

Phil Harvey

Wow, that's a lot of hit-n-miss.

Try this (the quoting assumes you are on Mac or Linux):

exiftool -PixelShiftResolution -Quality -if '$PixelShiftResolution eq "On"' -ext pef .

The 'eq' operator is used for string comparisons, and "On" must be quoted because it is a string.

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

StarGeek

Since I'm slow and had already typed all this out, here's some more details.

The PixelShiftResolution has a raw numeric value of 0 or 1, which exiftool will display (printConv) as a string of Off/On.  To do a string comparison, you would use eq to see if it is exactly equal (no substring search).  Also, as a string, what you are comparing to must be in quotes.  Case does matter in this comparison.  The type of quotes depends upon the system.  Phil shows the Mac/Linux version.  On Windows CMD, you need double quotes around the whole things and single quotes around the matching string (Powershell is different and I'm not sure exactly how to quote it there, possibly the same as Mac/Linux).  This should work under Windows:
-if "$PixelShiftResolution eq 'On' "

You can also compare the raw value.  In that case, you would add a hashtag to the end of the name, use the double equal sign ==, and wouldn't need to quote the value.
-if "$PixelShiftResolution# == 1"

Finally, you can use a regex match.  This allows for substring searches as well as case insensitive search option by adding a trailing i.
-if "$PixelShiftResolution =~/on/i"
* 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).

mblanchette

Thanks Phil.  I tried everything BUT putting doubles inside singles (Windows ).  This worked:

exiftool -Name -if "$PixelShiftResolution eq 'On'" .

Thanks again!