Using -if, what character(s) means a field isn't empty?

Started by ericconn, December 18, 2020, 10:59:32 PM

Previous topic - Next topic

ericconn

I'm trying to return a list of files that have a value in the keyword field, ignoring files with no keywords, for output to CSV. What do I put between slashes to signify a field has a value? Thanks so much.

exiftool -if "$keywords =~ /?/i" -keyword -csv "C:\Scan_Location" -r  "C:\Output.csv"

StarGeek

If the Keywords tag exists and has entries, then you can simply use
-if "$Keywords"

There are two edge cases where this will fail though, but they would be rare.  First is if Keywords exists but only contains one entry which is a empty string.  The second would be if it contains one entry with a value of the number 0.  That is because Perl would regard both of these as False.

Alternatively, you could use
-if "defined $Keywords"
which will only fail if Keywords does not exist.
"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