I am trying to combine the contents of IDF0:XPKeywords and XMP:Subject and write the combined list into XMP:Subject.
The following code seems to do it, except that where a keyword is in both XPKeywords and Subject it is duplicated in the output:
cd "\My Progs\ExifTool\Before"
"C:\My Progs\ExifTool\exiftool.exe" -k -r -sep "; " -addtagsFromFile @ "-Subject<Subject" "-Subject<XPKeywords" * -o "C:/My Progs/ExifTool/After/%%d/"
Is it possible to amend the code to avoid duplicates?
See FAQ 17 (http://www.exiftool.org/faq.html#Q17).
Thanks for your reply.
My problem is that some of my photo files have some keywords in Subject that are not in XPKeywords.
If I understand it correctly, FAQ 17 says that "exiftool -Subject<Subject" "-Subject<XPKeywords" avoids duplication by simply overwriting Subject with the contents of XPKeywords. That is what happened when I tried it (before I read about -addtagsfromfile). However, this means that keywords that are in Subject but not in XPKeywords are lost.
Quote from: Hugh on February 11, 2016, 04:23:25 AM
If I understand it correctly, FAQ 17 says that "exiftool -Subject<Subject" "-Subject<XPKeywords" avoids duplication by simply overwriting Subject with the contents of XPKeywords.
The above command is the same as
exiftool "-Subject<XPKeywords"You want this to keep the original items and add new ones avoiding duplicates:
exiftool -addtagsfromfile @ "-subject-<xpkeywords" "-subject+<xpkeywords" -sep "; " DIR- Phil
Thanks. I missed the + .
The "+" makes no difference in this command. It is assumed since there was a "-" in another copy (and -addTagsFromFile was used, so the earlier copy wasn't overridden).
- Phil
I've just seen your reply to my last post.
Yes, I realised that I had also missed the -< !!!
I now understand the logic ... remove from Subject the tags that are duplicated then add to Subject all the tags that are in XPKeywords.
My test file looks good. I'll now try it out on a whole month's worth of photos.
Thanks again.