CSV export of single List-type tags values ?

Started by DafOwen, July 07, 2020, 11:05:09 AM

Previous topic - Next topic

DafOwen

Is it possible to export (CSV) only some items from a list-type tag ?

My scenario : I have a bunch of jpg files with a certain code in their keywords (IPTC:keywords and/or XMP:Subject) and want to export just this code.
Code starts with IS

I've managed to export XMP:Subject for just those with the code using:
exiftool -csv -XMP:Subject A162-*.jpg > outputCodes.csv -if "$XMP:Subject=~/IS/"


but I want to export just the code, not all values in the list.

So e.g. of what I want in CSV:

SourceFile,Subject
A162-0001.jpg, IS185-012
A162-0002.jpg, IS185-013
A162-0003.jpg, IS185-014

Thanks

StarGeek

Will you be including other tags in you CSV output other than the IS keywords?
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

DafOwen

Have found a way around this by using a different program (Excel + SEARCH/MID functions)

Was looking for just the IS* keyword (+original filename) no other tags no other list items.

StarGeek

Glad you figured it out.

I would be pretty complex to do in exiftool.  You would need to remove all Subject keywords that didn't match your pattern.  I could be wrong but I don't think this is possible using the basic -csv option.  Instead, I think the -p (printFormat) option would need to be used.

This seems to work with my quick test, though it doesn't have column headers.  This would be the command for Windows, Mac/Linux would need different quoting.
exiftool -p """"$Directory#\$filename#""",${subject@;$_=undef if !/^IS/}" /path/to/files/ >file.csv

Other tags could be added to this by using the -api Filter option listed near the end of FAQ #12.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).