I am trying to copy two tags from one file to another file, and merge the Keywords from the source to the destination.
First I tried
exiftool -tagsFromFile srcfile -DateTimeOriginal -Caption-Abstract -Keywords dstfile
but it simply copied the keywords.
Then I tried
exiftool -addTagsFromFile srcfile -DateTimeOriginal -Caption-Abstract -Keywords dstfile
but the same thing happened.
Then I re-read the man page and FAQ17 (http://www.exiftool.org/faq.html#Q17 (http://www.exiftool.org/faq.html#Q17)), which says "To add to or remove from the existing keywords, use '+<' or '-<'."
exiftool -tagsFromFile srcfile -DateTimeOriginal -Caption-Abstract -Keywords+<Keywords dstfile
which did what I expect, but gave me an error:
Warning: Shift value for XMP-pdf:Keywords is not a number
Is there a more appropriate approach, that gives no error?
And better, how can I merge rather than append to the list of keywords? That is, I want the resulting list to be a set (no duplicates).
thanks!
dave
Hi Dave,
I'm glad to see you found the FAQ.
I think the only thing you are missing is the quotes you need when there are special characters like ">" or a space in an argument:
exiftool -tagsFromFile srcfile -DateTimeOriginal -Caption-Abstract "-Keywords+<Keywords" dstfile
To merge, first delete then add the keywords (ensures you don't have duplicates):
exiftool -addTagsFromFile srcfile -DateTimeOriginal -Caption-Abstract "-Keywords-<Keywords" "-Keywords+<Keywords" dstfile
- Phil
Edit: Oops. I forgot one thing. The deleting and adding back again to the same list requires the -addTagsFromFile option (which I changed in the 2nd command above), otherwise the 2nd assignment overrides the first. Tricky I know.
Also, you can ignore the XMP-pdf:Keywords warning. Alternatively, you can specify the exact Keywords tag you want to copy ("IPTC:Keywords" probably), so ExifTool doesn't try to update the XMP-pdf:Keywords.
Thanks for the quick response. I know about the need for quoting special characters -- and do that, when I run the command from the shell -- but I'm actually running exiftool from within Python (long story) and don't need the quotes there.
You are correct that I want IPTC:Keywords, so I'll switch to that form.
Thanks!
dave