Incorrect comparison results when using -if option

Started by Archive, May 12, 2010, 08:54:42 AM

Previous topic - Next topic

Archive

[Originally posted by ryerman on 2009-11-17 06:33:03-08]

I want to sort JPEG images according to image size so tested this command:

exiftool -k -ImageWidth -if "$ImageWidth# ge 600"

with these results:

Files with Image Width from 1 to 6 fail the condition with the message "1 files failed condition", as expected.

.................................................7 to 9 pass the condition and the tag value is returned, which was not expected.

.................................................10 to 60 fail as expected.

.................................................61 to 99 pass, which was not expected.

.................................................100 to 599 fail as expected.

.................................................600 to 999 pass as expected.

.................................................1000 to 5999 fail, which was not expected.

The 600 in the -if option is arbitrary but it seems to define some pattern. I suspect a similar pattern would be created by any value.

It seems that when &ImageWidth# has 3 digits (as 600 does) that the comparison is accurate. Otherwise, the comparison is, sometimes, flawed.

Or, more likely, I've missed some switch or setting or format specification.

Also, I didn't try every value in the ranges mentioned above, just values around 6, 60, 600, and 6000 because they seemed pertinent.

Please explain how to make accurate comparisons for Image Width and Image Height.

Windows Vista, ExifTool 7.99

-Jim

Archive

[Originally posted by exiftool on 2009-11-17 11:45:43-08]

Hi Jim,

The string equality operator "eq" works for numbers only
if they have the same number of digits.  You should use the
numerical equality operator "==" instead.

I hope this makes sense.

- Phil

Archive

[Originally posted by exiftool on 2009-11-17 11:46:52-08]

I wish this forum had an edit feature.

I should have said:  Use ">=" instead of "ge".

- Phil

Archive

[Originally posted by ryerman on 2009-11-17 13:28:31-08]

Hi Phil, and thank-you.

The comparisons now work as they should.  I tried other operators (less than, less than or equal, etc.) and now understand how to make accurate comparisons.

When I use -if options to control directory renaming I'll really have something!  
  As you say, file renaming/moving is a powerful feature.

Thanks again,

-Jim