Duplicate and extraneous metadata shown when using '-if 1'

Started by User93848562, September 29, 2024, 06:41:18 PM

Previous topic - Next topic

User93848562

I'm encountering some funny behavior with excess metadata shown, and I'm unsure if it's user error, an issue with the file format, or a legitimate ExifTool bug. I've been able to reproduce this behavior across three different versions of ExifTool (v12.50, v12.76, v12.97).

Specifically, when I run exiftool -args -if 1 <FILE.ARW>, I get about 90 more tags than if I run exiftool -args <FILE.ARW>. My understanding is that -if 1 should be a no-op.

I'm able to reproduce this behavior with all my ARW files.

Phil Harvey

Good point.  I should document this.

Using the -if option implies -a to allow duplicate tags to be extracted.  This is in case the -if condition makes use of these tags.

- 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

Quote from: User93848562 on September 29, 2024, 06:41:18 PMMy understanding is that -if 1 should be a no-op.

Using -if 1 will always evaluate to true. So that command will always be processed.
"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

User93848562

Would it make sense to only implicitly invoke the -a option if the -if refers to a one of those duplicated tags? It seems that would be the least "surprising" behavior.

Case in point, I stumbled on this behavior because I wanted to gather some statistics on the EXIF data of my photos, but only of the RAW ones I took. I issued this command, thinking all my original files were RAW:

exiftool -args -recurse Originals/

But turns out I had JPEGs (and some other image types) dispersed in the directory hierarchy. So I issued this command instead, thinking it would weed out all other file types but otherwise behave as above:

exiftool -args -recurse -if '$filetype eq "ARW"' Originals/

But that includes the duplicate tags now, and --a doesn't seem to negate that behavior. It seems the only way to accomplish my task is to invoke exiftool multiple times, which is significantly slower:

find Originals/ -type f -iname '*.arw' -exec exiftool -args '{}' +

User93848562

QuoteUsing -if 1 will always evaluate to true. So that command will always be processed.

Yes, hence it's a no-op, no?

StarGeek

"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

User93848562

That's great, thank you!

IMHO, it's still worth considering rejiggering the output of commands using -if to be more consistent with those without it (for those cases where the argument to -if doesn't reference duplicate tags), for users who are filtering on something other than file extension.

That being said, it is fortunate for my particular use case that there's the -ext argument, so thank you again for pointing me to it.

Phil Harvey

Quote from: User93848562 on September 29, 2024, 10:43:40 PMWould it make sense to only implicitly invoke the -a option if the -if refers to a one of those duplicated tags?

ExifTool doesn't know if there are duplicate tags until after extracting them with the -a option.  Also, it seems even more confusing to me if the behaviour depends on the tags used in the expression.  (Also, more complicated logic and harder to document.)

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