Handling of undefined tags in -if condition when -m option is used

Started by U_turn, September 12, 2024, 10:24:21 AM

Previous topic - Next topic

U_turn

I have used exiftool version 10.26 for years to filter image files on conditional tag and formatting print output, but after upgrading to version 12.96 I have noticed different behavior: files are listed as having conditional tag even they don't...

I have started to check why do I get different results and noticed that it is related to "-m" option and changes done in exiftool version 12.60...

As per changelog of 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

I do believe it refers to this documentation part:
"If a specified tag does not exist, a minor warning is issued and the line with the missing tag is not printed. However, the -f option may be used to set the value of missing tags to '-' (but this may be configured via the API MissingTagValue option), or the -m option may be used to ignore minor warnings and leave the missing values empty. Alternatively, -q -q may be used to simply suppress the warning messages."

Maybe it was meant this way, but I find it very odd that -if returns wrong results while -m is related to -p (output format) option... If someone is willing to filter image files without defined specific tag and format output with -m, he/she can't do this in one pass... For example:

exiftool-1259.exe DSC*.JPG -if "defined $imageuniqueid" -p \"$directory/$filename,$dateacquired\" -m
3 files failed condition
0 image files read

exiftool-1260.exe DSC*.JPG -if "defined $imageuniqueid" -p \"$directory/$filename,$dateacquired\" -m
"./DSC_0320.JPG,"
"./DSC_0321.JPG,"
"./DSC_0380.JPG,"
3 image files read

StarGeek

Here's the relevent thread.

The releveant documentation is in the -m (-ignoreMinorErrors) option
QuoteNote that this causes missing values in -tagsFromFile, -p and -if strings to be set to an empty string rather than an undefined value.

This is how it was documented for a long time (Archive.org, Dec 5, 2019). Technically, this was a fix for a long-standing bug.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

U_turn

Thanks for pinpointing to an old thread.
I see that Phil has hesitated to introduce "fix", but did it anyway.

I would have never guessed that "ignoring minor errors and warnings" option may cause getting false results in conditional clause. Has anyone thought about fixing documentation and not breaking the logic why conditional clause is used in the first place? I mean... What's the point of having -if "defined" in case -m ruins the results? Implementation/usage of -if with -m looks too complicated...

StarGeek

This is just my opinion, but the -m should never be used as a default option. There have been far too many times when I've gone round and round trying to figure out someone's problem that could have be figured out instantly by not including it. You should want to know when there's a problem with the file.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype