I am using a command:
exiftool -csv -caption-abstract -keywords *.jpg
to produce a csv file with the caption and keywords. This works as expected, producing a csv file with three columns, the SourceFile, the caption, and the keywords. The keywords are quoted if there is more than one. If a file does not have a caption, then that field is empty, represented by two commas in succession.
However, if none of the image files contain a caption, then that column is removed entirely, resulting in a file with just two columns, the SourceFile and the keywords. This disrupts further processing because the post-processing program expects a 3 column file.
Is there any way to force exiftool to produce columns even if none of the image files contain data in that field?
Thanks,
You can use the -f (-ForcePrint) option (https://exiftool.org/exiftool_pod.html#f--forcePrint). It will print a hyphen - for any tag that doesn't exist. This can be changed with the -api MissingTagValue option (https://exiftool.org/ExifTool.html#MissingTagValue).
Great, thanks. The -f option works to force the column to exist, and I can use missingTagOption to set what it writes for missing tags. But I can't seem to get it to write an empty string. If I do:
exiftool -f -api missingtagvalue="" -csv -caption-abstract -keywords *.jpg
it still writes a hyphen for missing values.
The closest I could come was to use missingtagvalue=" ", which produces " " in the output - that is, quote-space-quote is written to the output file for that field.
Is there any way to get missingtagvalue to write an empty string? This isn't essential, as I can deal with " " in the file, but it would be nice.
Thanks for your help,
Exiftool 12.58 on Windows 10
You need to use this trick to set any tag or option to an empty string:
-api missingtagvalue^=
Otherwise, the tag or option is deleted. The quotes are parsed by the command shell, and not seen by ExifTool. So unfortunately missingtagvalue="" is the same as missingtagvalue= as far as ExifTool is concerned. (Hence the invented work-around of ^=.)
- Phil
If I write it just like that
-api missingtagvalue^=
I still get a hyphen in the output file. But if I quote the missingtagvalue part, like this:
-api "missingtagvalue^="
then it writes an empty field. I think Windows is treating the unquoted caret ^ as an escape character. But interestingly, if I quote the whole phrase
"-api missingtagvalue^="
I get Warning: Tag 'api' is not defined. I still don't understand command shell escaping rules!
Anyway, this works. Thanks to both of you for your help, you're great!
You're right. I forgot about the caret being special in Windows.
You can't put quotes around both arguments because it turns them into a single argument.
- Phil
Since the caret is an escape character in CMD, you have to escape it with another caret
Example, where "FakeTag" ends up with a empty cell
C:\>exiftool -G1 -a -s -csv -f -api missingtagvalue^^= -FakeTag -Description y:\!temp\Test4.jpg
SourceFile,Unknown:FakeTag,XMP-dc:Description
y:/!temp/Test4.jpg,,Test