[Originally posted by eric80 on 2009-05-19 23:30:10-07]
I am using exiftool exe.
I like to set many fields at once but only if they are empty. For instance,
exiftool -IPTC:ObjectName="myname" -IPTC:Caption-Abstract="my caption"
should set the name only if the current field is empty, and independently the caption if empty. Is it possible to do that?
According to the doc, I cannot use the -if option ("When multiple -if options are used, all conditions must be satisfied to process the file")
The += or -= are only for add and remove, don't they?
[Originally posted by exiftool on 2009-05-20 11:21:25-07]
Your idea of using the -= was correct:
exiftool -iptc:objectname-= -iptc:objectname="myname" -IPTC:Caption-Abstract-= IPTC:Caption-Abstract="my caption" FILE
The "-tag-=" syntax deletes a tag only if it was empty,
which of course doesn't make any sense by itself but when this is
combined with an assignment of the same tag then the tag you
assign is only written if the original tag was empty.
- Phil
[Originally posted by eric80 on 2009-05-20 23:06:30-07]
Thanks for your answer and powerful tool!
So here is my cmd
Exiftool.exe -IPTC:Headline-= -IPTC:Headline="my title" -IPTC:ObjectName-= -IPTC:ObjectName="my title" -IPTC:Caption-Abstract-= -IPTC:Caption-Abstract="my caption" -IPTC:Writer-Editor-= -IPTC:Writer-Editor="Eric" -IPTC:Keywords-= -IPTC:Keywords="key1,key2" img.jpg
it works pretty good for headline, objectname, caption, but NOT for keywords: the new keywords are always appended to the existing ones. If I execute the cmd a 2nd time, I get key1,key2,key1,key2 in keywords! Or key1,key2,key3 if I put "key3" in the cmd.
A bug? I am using v7.75
Further question: I am not sure about the use of Headline and/or ObjectName to set the title for my picture. Headline seems more appropriate (and longer string allowed), but what is OjectName for?
[Originally posted by exiftool on 2009-05-21 11:16:06-07]It is not a bug. The
+= and
-= operators have a special meaning
for List-type tags. For these, you must add and delete individual
keywords. So you must do this to be sure you have only one copy
of each keyword:
-IPTC:Keywords-=key1 -IPTC:Keywords=key1 -IPTC:Keywords-=key2 -IPTC:Keywords=key2
See
FAQ
number 17 for examples of working with List-type tags.
- Phil