News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Combined Keywords user defined tag

Started by StarGeek, April 17, 2021, 07:22:08 PM

Previous topic - Next topic

StarGeek

I thought I had posted something like this at one point, but can't find anything.

This is a config file for a user defined tag that will combine all entries in the IPTC:Keywords, XMP:Subject, and XPSubject, strip any duplicates, and return the results.

example use
exiftool -config CombineKeywords.config "-Keywords<CombineKeys" "-Subject<CombineKeys" /path/to/files/

# Config file to combine the keywords in IPTC:Keywords, XMP:Subject, and XPKeywords
# Removes the duplicates and empty entries.

%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
CombineKeys => {
Desire => {
0 => 'Keywords',
1 => 'Subject',
2 => 'XPKeywords',
},
ValueConv => q{
my @ListKeys    = ref $val[0] eq 'ARRAY' ? @{$val[0]} : (defined $val[0] ?( $val[0] ):());
my @ListSubject = ref $val[1] eq 'ARRAY' ? @{$val[1]} : (defined $val[1] ?( $val[1] ):());
my @list  = ();
my @list2 = ();
my %seen  = ();
push (@list, @ListKeys);
push (@list, @ListSubject);
push (@list, split(/;/,$val[2])) if defined $val[2];
@list2 = grep { ! $seen{ $_ }++ } @list; #Remove duplicates
@list2 = grep { !/^\s*$/ } @list2; #Remove blank Keywords and subjects
return  \@list2;
},
},
##############
},
);
#------------------------------------------------------------------------------
1;  #end
* 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).