Searched the forum and online but couldn't find an example to parse through list values.
Basically, I'd like to read each value in the Microsoft People schema XMP-MP-RegionPersonDisplayName
and add it to XMP-dc:subject and IPTC-keywords if they don't currently exist there.
Any advice would be appreciated.
Try this:
exiftool -addtagsfromfile @ "-xmp-dc:subject-<XMP-MP:RegionPersonDisplayName" "-xmp-dc:subject+<XMP-MP:RegionPersonDisplayName" "-iptc:keywords-<XMP-MP:RegionPersonDisplayName" "-iptc:keywords+<XMP-MP:RegionPersonDisplayName" DIR
FAQ 17 (https://exiftool.org/faq.html#Q17) describes the technique I used here to avoid duplicate entries.
- Phil
You are the master!
Thanks for this wonderful piece of software...
One minor issue, keywords are duplicated if they previously existed.
Shouldn't be
Right again, it was a typo!
Hi Phil,
I have a follow-up question.
I'm sure this can be done programmatically, but it may be too complex for the command line / batch file.
I want to check each person name in XMP-MP:RegionPersonDisplayName list for a matching value in IPTC:keywords.
Output the person name if condition is true (no matching name).
Thanks.
That can be done with this command:
exiftool -config missingnames.config -missingnames DIR
and this config file:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
MissingNames => {
Require => {
0 => 'XMP-MP:RegionPersonDisplayName',
},
Desire => {
1 => 'IPTC:Keywords',
},
ValueConv => q{
my @people = ref $val[0] ? @{$val[0]} : ( $val[0] );
my @keywords;
@keywords = ref $val[1] ? @{$val[1]} : ( $val[1] ) if defined $val[1];
my %keys;
$keys{$_} = 1 foreach @keywords;
my @out;
$keys{$_} or push @out, $_ foreach @people;
return @out ? \@out : undef;
},
},
},
);
1; #end
- Phil
Thanks so much.
Worked like a charm.
Didn't even consider config files.
What programming language do they use?
Quote from: bigfire60 on March 20, 2020, 12:13:17 PM
What programming language do they use?
Exiftool and the config files are Perl programs. Even the Windows executable is just PAR packed Perl code (https://en.wikipedia.org/wiki/Perl_Archive_Toolkit).
Very good, thanks.
Unfortunately, I don't know Perl.
I took a stab but couldn't figure out how to also output the filename when the condition is true.
Could you be so kind?
Just use the same config file
exiftool -config missingnames.config -if "$missingnames" -Filename <FileOrDir>
Now it will output the filename, but not the missing names.
The attached screen capture show the initial run without the if condition
where the missing names appear. The last run shows the filename but not the missing name.
Oops, just had to add the -missingnames to the list.
Is there a way to suppress the linefeed between Filename & missing name?
See the -p (printFormat) option (https://exiftool.org/exiftool_pod.html#p-FMTFILE-or-STR--printFormat) to format the output as you would like.
Perfect.
Thanks StarGeek.