Hi.
congratulations for the software, it's great.
I have a problem I cannot resolve, maybe you can help me.
I want to copy all my XMP-mwg-rs:RegionName (written by Picasa face tags) to IPTC:Keywords, to make all the people in a photo avaible in every other programs, like Adobe Lightroom.
I did this script:
exiftool -k -overwrite_original -IPTC:keywords-<XMP-mwg-rs:RegionName -IPTC:keywords+<XMP-mwg-rs:RegionName C:\Users\Simone\Dropbox\Immagini\Album\test
but it creates me duplicates, don't know why.
Another thing... I have about 4000+ photos in a dropbox folder. I need each file to be updated only if needed, namely when in a photo there is a XML regionName than is not present in IPTC Keywords.
Otherwise everytime I run the script dropbox will re-sych all the 4000+ photo, when only 5-6 really needed.
Thank you.
This is a bit tricky, but the reason is explained in note 5 of the -tagsFromFile documentation:
5) The normal behaviour of copied tags differs subtly from that of
assigned tags for list-type tags. When copying to a list, each
copied tag overrides any previous operations on the list. While
this avoids duplicate list items when copying groups of tags from
a file containing redundant information, it also prevents values
of different tags from being copied into the same list when this
is the intent. So a -addTagsFromFile option is provided which
allows copying of multiple tags into the same list. ie)
exiftool -addtagsfromfile @ '-subject<make' '-subject<model' ...
Other than this difference, the -tagsFromFile and -addTagsFromFile
options are equivalent.
One might think that the -< and +< would change this, but they don't since the +/- applies to adding/deleting tags in the target file, and doesn't affect the the tags accumulated from the command line.
The only way I can see to avoid updating the file when all of the regions already exist in the keywords is to create a user-defined Composite tag based on IPTC:Keywords and XMP-mwg-rs:RegionName. Then construct the new list yourself, or return undef if nothing changed (then the file won't be changed).
- Phil
I was feeling generous, so here is the config file to define the Composite tag I mentioned (called MyKeywords). See the sample config file (https://exiftool.org/config.html) for instructions on activating the config file.
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
MyKeywords => {
Require => {
0 => 'XMP-mwg-rs:RegionName',
},
Desire => {
1 => 'IPTC:Keywords',
},
ValueConv => q{
my (@key, %key, $changed);
my @reg = ref $val[0] eq 'ARRAY' ? @{$val[0]} : ($val[0]);
@key = ref $val[1] eq 'ARRAY' ? @{$val[1]} : ($val[1]) if defined $val[1];
$key{$_} = 1 foreach @key;
foreach (@reg) {
next if $key{$_};
push @key, $_;
$changed = 1;
}
return $changed ? \@key : undef;
},
},
},
);
1; # end
With this, the command would be:
exiftool "-iptc:keywords<mykeywords" FILE
- Phil
Edit: Removed a useless line from the code.
This is simply beautifull, works as expected.
Thanks for your time, very appreciated.
Thankyou Very Much!
and Congratulation ! This is a great software! ;D
*so* close.
I'm interested in getting this exact thing to work. I've created the config file as in the example, but the result is not updating the Keywords tag:
$ exiftool "-mykeywords" DSC00315.JPG
My Keywords : Foo, Bar
$ exiftool "-iptc:keywords<mykeywords" DSC00315.JPG
0 image files updated
1 image files unchanged
And adding -addTagsFromFile doesn't help either:
$ exiftool '-addTagsFromFile @' "-iptc:keywords<mykeywords" DSC00315.JPG
0 image files updated
1 image files unchanged
Thanks in advance.
Edit to add (in case it's relevant): $ exiftool -ver
8.60
Nevermind. I tried the latest version (9.63) and it works there, so my only problem was the version.
This should have worked with 8.60. Your quoting is wrong though:
Quoteexiftool '-addTagsFromFile @' "-iptc:keywords<mykeywords" DSC00315.JPG
You shouldn't have quotes around
'-addTagsFromFile @'.
- Phil
Without the quotes:
$ exiftool -addTagsFromFile @ "-iptc:keywords<mykeywords" DSC00315.JPG
Error: Error opening file - @
0 image files updated
1 image files unchanged
1 files weren't updated due to errors
The current version works without this, of course.
I don't understand. The -addTagsFromFile option was added in version 7.37.
Oh well. No need to worry about what may have changed since the current version is working for you.
- Phil