Author Topic: CSV export of single List-type tags values ?  (Read 133 times)

DafOwen

  • Newbie
  • *
  • Posts: 2
CSV export of single List-type tags values ?
« on: July 07, 2020, 11:05:09 AM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3949
Re: CSV export of single List-type tags values ?
« Reply #1 on: July 07, 2020, 11:42:26 AM »
Will you be including other tags in you CSV output other than the IS keywords?
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

DafOwen

  • Newbie
  • *
  • Posts: 2
Re: CSV export of single List-type tags values ?
« Reply #2 on: July 07, 2020, 11:46:08 AM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3949
Re: CSV export of single List-type tags values ?
« Reply #3 on: July 07, 2020, 12:16:08 PM »
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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.