[Originally posted by patrickcunningham on 2008-03-29 09:31:53-07]
I am extremely grateful for exiftool. I was looking at weeks of manual processing to manipulate the keywords in nearly 4,000 tif files. Exiftool to the rescue!
I've achieved 3/4 of what I need to do, but I'm stuck on pretty much the last bit.
I have .xmp files in a sub-directory called xmp. Most xmp files have keywords in the XMP-lr:HierarchicalKeywords bag container and the same keywords in the dc:Subject bag container. But some do not have the lightroom lr: verion, just the dc: ones. These are the only tags I saved to the .xmp files originally. They have been manipulated elsewhere, and I now need to write them back to the .tifs, overwriting the original keywords.
I have tried various commands using the exiftool.exe version to write both sets of keywords to the tif files, but the best I can do is to get lr: but not dc: into files with lr: and dc:, and dc: into files with dc: but no lr: (in which case the keywords also overwrite the versions in Photoshop:Keywords and xap:Keywords, which is ideal).
I think the problem relates to Note 3. in the -TagsFromFile documentation, but I just can't get my head around how to write the command.
The following gets the result referred to above: exiftool -TagsFromFile %d/xmp/%f.xmp dir
I tried:
exiftool -TagsFromFile %d/xmp/%f.xmp -XMP-dc:Subject -XMP-lr:HierarchicalSubject dir
exiftool -TagsFromFile %d/xmp/%f.xmp --XMP -XMP-lr:HierarchicalSubject -dc:Subject dir
exiftool -TagsFromFile %d/xmp/%f.xmp -all:all dir
(dir is the directory holding the tif files)
I could use the workaround of -TagsFromFile @ to copy the keywords from one field in the file to the others, but it would require less steps if I could get this to work.
Patrick Cunningham
[Originally posted by exiftool on 2008-03-29 13:55:42-07]
Hi Patrick,
It seems that you want to copy dc:Subject to the new file if it
exists, and otherwise to write lr:HierarchicalSubject to dc:Subject.
Correct me if I'm wrong, but doesn't this do what you want?:
exiftool -tagsfromfile %d/xmp/%f.xmp "-xmp-dc:subject<hierarchicalSubject"
-xmp-dc:subject DIR
- Phil
[Originally posted by patrickcunningham on 2008-03-29 15:28:27-07]
Hello Phil, and thank you for your quick response. Unfortunately it didn't do the job. I'll try to clarify.I used exiftool to generate xmp files with dc:Subject and lr:HierarchicalKeywords (only); but some of the original tiffs did not have the lr: tag, so those xmp files have only the dc: tag set of keywords
I manipulated the keywords (deleted some, changed the case of others). The way I did this was automated, and changed both sets of keywords (where they were present)
I'm now trying to write the resulting tags from the xmp files back to the tiffs; it works for the files which have no lr: tags. The dc:Subject set of keywords is written to the three instances of keywords in the tiff files.
However, the tiffs with both lr: and dc: tags have the new version keywords in the lr: tags only, and the old verion in the dc: tags (and the other instances). I need to write the new version to all instances of Keywords in the tiff files, regardless of whether there is a lr: tag or not. It doesn't matter if they come from the dc:Subject tag or the lr:HierarchicalKeywords tag in the xmp files - the sets are identical.
Best regards - and thanks again for this powerful tool!
Patrick
[Originally posted by exiftool on 2008-03-30 11:48:33-07]Hi Patrick,
When you say "three instances of keywords", what is the third?
IPTC:Keywords? If so, and if you always want to write all three,
then the arguments are the same as I wrote above, but you do
it once for each tag (I write this in the form of an argfile):
-tagsfromfile
%d/xmp/%f.xmp
-xmp-dc:subject
-xmp-dc:subject<hierarchicalSubject
-xmp-lr:hierarchicalsubject<xmp-dc:subject
-xmp-lr:hierarchicalsubject<hierarchicalSubject
-iptc:keywords<xmp-dc:subject
-iptc:keywords<hierarchicalSubject
Here I changed the order so the lr hierarchicalsubject comes last
since it seems from your description that it may contain the newer
version of your keywords. Also, throughout you have called it
hierarchicalkeywords, but exiftool only writes hierarchicalsubject
in XMP-lr.
Now, if you want to only write the keywords tags that already exist
in the TIFF image, you have to do this with 3 separate commands,
and use conditions like
-if "defined $iptc:keywords" to
execute the command only if IPTC:Keywords exists.
- Phil
[Originally posted by patrickcunningham on 2008-03-30 13:36:51-07]Hello Phil
The files all have:
dc:Subject
Photoshop:Keywords
xap:Keywords
Some of them have lr:HierarchicalSubject in addition -(My mistake about the Keywords/Subject confusion!)
Come to think of it, some of the files may have the IPTC:Keywords tag as well, although none of the small selection I've been using for my tests do.
All I'm trying to achieve is a viable Lightroom catalog. Obviously, if Lightroom finds the lr:HierarchicalSubject tag, that's what it uses. If the tag is not present, I'm not sure which keywords/subject tag it looks in next. I can easily run a test to find out, but for the sake of consistency I would prefer to write to all of the tags which exist.
There is no difference between the sets of keywords within each of the xmp files, so it isn't important which is first or last.
I can't see that there would be any problem if new tag groups were added to the tiff files. Do I understand correctly that using the argfile from your post would do the following for each file in the batch:
-xmp-dc:subject
- copy dc:subject from xmp file to tiff, creating dc:subject if it doesn't exist
-xmp-dc:subject<hierarchicalSubject
- copy hierarchicalsubject (if it exists) from xmp file to dc:subject in the tiff
-xmp-lr:hierarchicalsubject<xmp-dc:subject
- copy dc:subject from xmp file to hierarchicalsubject in the tiff, creating lr:HierarchicalSubject if it doesn't exist
-xmp-lr:hierarchicalsubject<hierarchicalSubject
- copy hierarchicalsubject from xmp file to hierarchical subject in the tiff
-iptc:keywords<xmp-dc:subject -iptc:keywords<hierarchicalSubject
- (etc)
From the tests I've run, it seems that it is not necessary specifically to copy to each instance of keywords/subject, but I'm not clear under what circumstances the changes cascade through the tags.
Patrick
[Originally posted by exiftool on 2008-03-30 16:56:52-07]
Hi Patrick, I think we understand each other now. My example
copied both dc:suject and lr: hierarchicalsubject in that order
so hierarchicalsubject would take precedence. I wrote them
to all three tags, but I think a better idea would be to write
them to dc:subject and hierarchicalsubject, and to delete
the others if they exist (ie. -keywords=). It's slow typing on
my iPod, so I hope that's enough to get you going. -Phil
[Originally posted by patrickcunningham on 2008-03-30 18:07:07-07]
Thanks Phil. I'm not in the office today but I'll give it a go tomorrow; I think I understand the syntax now, thanks to your help. I'll let you know either way.
Patrick