Export count of Subject items/keywords?

Started by justmike, June 13, 2017, 10:15:17 AM

Previous topic - Next topic

justmike

Is it possible to create a counted/calculated column when exporting to a CSV? What I would like is a count of the keywords. I can do it in excel, but I am always in favor of knocking a step out.

StarGeek

* 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).

justmike

Quote from: StarGeek on June 13, 2017, 11:09:43 AM
See this thread.

Thanks—when I ran that, I got:
${keywords;$_=()=$self->GetValue('Keywords')}: bad substitution

Phil Harvey

If you are on Mac/Linux you need to change the quotes around 'Keywords' to double quotes, then put single quotes around the whole argument.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

If you're using the -csv export option, you might want to use the user-defined tag in that thread.  If you don't already have a .exiftool_config file, grab the example config file, rename it according to the instructions in the file, and copy the text of the KeywordCount tag, find the lines where it says
# Composite tags are added to the Composite table:
    'Image::ExifTool::Composite' => {

and insert it on a new line right after that so it looks like

# Composite tags are added to the Composite table:
    'Image::ExifTool::Composite' => {
    KeywordCount => {
        Require => 'Keywords',
        ValueConv => q{
            my @list = ref $val ? @$val : ($val);
            return scalar @list;
        },
    },


You can then use KeywordCount as a tag in your command.
* 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).