Is there a way to use EXIFTool to remove IPTC keyword duplicates? I am not sure how they got into my metadata, but now I believe the duplicates are causing me problems because certain programs won't let me delete keywords that are duplicates.
My followup question is can EXIFTool be configured to remove leading spaces from keywords? Again, I am not sure how it happened but it appears that sometimes I now have what certain programs consider to be duplicates even though they are not...i.e. " Germany" is not the same as "Germany" but programs treat them as the same. I did not notice this issue when it happened, but (as above) now certain programs are not letting me delete or change keywords if I have (1) "Keyword" as well as (2) "LeadingSpace+Keyword"
Thanks in advance - your software is a great tool and probably my only chance to fix these issues in batch without lots of manual effort.
Here is a config file (https://exiftool.org/config.html) that will do it with this command:
exiftool "-keywords<mykeywords" DIR
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
MyKeywords => {
Require => 'Keywords',
ValueConv => q{
my @list = ref $val eq 'ARRAY' ? @$val : $val;
my ($item, %found, @rtn);
foreach $item (@list) {
$item =~ s/^\s+//; # remove leading white space
push @rtn, $item unless $found{$item};
$found{$item} = 1;
}
return \@rtn;
},
},
},
);
1; # end
- Phil
Wow - that is truly amazing. Your software is, again, great. Thanks for saving me so much time.
Thanks. This works and saved me a lot of time.