Bug? introduced in 12.60: If clause combined with "-m"

Started by karlgustavv, May 01, 2023, 04:44:06 AM

Previous topic - Next topic

karlgustavv

OS: Windows 10

If you got a folder containing 3 jpg files and want to get those that don't have an ISO tag you might use:
exiftool_12.59.exe -if "not defined $ISO" -m *.jpg

Output will be:
======== no_iso.jpg
ExifTool Version Number         : 12.59
File Name                       : no_iso.jpg
Directory                       : .
...
Image Size                      : 4500x2532
Megapixels                      : 11.4
    2 files failed condition
    1 image files read

If you use the same command with 12.60 (or 12.61):
exiftool_12.60.exe -if "not defined $ISO" -m *.jpg

Output will be:
    3 files failed condition
    0 image files read

If you omit "-m" it will work as expected:
exiftool_12.60.exe -if "not defined $ISO" *.jpg

Output will be:
======== no_iso.jpg
ExifTool Version Number         : 12.60
File Name                       : no_iso.jpg
Directory                       : .
...
Image Size                      : 4500x2532
Megapixels                      : 11.4
    2 files failed condition
    1 image files read

I usually use that if clause in combination with "-tagsfromfile" within a batch file. Omitting "-m" is not an option in that case.

Phil Harvey

The behaviour of 12.59 was contrary to the documentation.  This was fixed in 12.60:

Apr. 5, 2023 - Version 12.60 (production release)
  - Fixed handling of undefined tags in -if conditions to conform with
    documentation and match -p and -tagsFromFile behaviour when -m or -f option
    is used


Undefined tags are set to an empty string when the -m option is used.

I would suggest changing the condition to -if "not $iso" to handle both cases (with and without -m).

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

karlgustavv

Thank you very much for the explanation and the easy solution.