I have thousands of photographs that I'm about to import into Lightroom. For each file, I have a number of keywords that I want to add to the keyword metadata as the file. (I don't really care what "field" the keywords end up in in the lightroom catalog metadata; I just want to be able to search on strings in lightroom and to have it find any matches with these keyword strings.)
In particular, I have many .nef files and many .jpg files. For both types of files, I have the metadata keywords I want to add in both a .txt file and a .xmp file (I wrote these .xmp files programmatically, and they appear to be in the correct format). In the case of the .nef files, when I import them into lightroom the keywords in the .xmp are brought in correctly, and I see them in the metadata panel when viewing the photo in lightroom. But with the .jpg files it does not bring in the metadata from the .xmp files. I believe this is because lightroom assumes any metadata for the file will be embedded in the .jpg file so no need to look for an .xmp. (And in fact many of my .jpg files *do* contain embedded metadata, so what I was hoping was that lightroom would respect that metadata *and* add to it with the .xmp file data, but alas.)
It seems like a lightroom sdk lua script may be the solution to the problem.
I am given hope by this thread: http://forums.adobe.com/thread/949333?tstart=0
What I'm looking for here is:
(a) Can you confirm that what I am doing is possilbe? That is: That I can write a lua script to read the metadata out of my external files and apply that metadata to the corresponding pictures in the catalog (this is after I've imported everything into lightroom in the normal way).
(b) Can you give me pointers to some of the specific functions I'll need to do this? The thread metioned above refers to LrPhoto:setRawMetadata(), which sounds very promising. Is there a particular way I want to use that function to write my metadata as "plain old" keywords that are searchable? Also, I'll need a way to determine which metadata goes with which file. That is, when I do the import I will be importing a tree of files. In some cases a .jpg in one directory will have the same file name as a .jpg in a different directory. So I'll need to look at the file's whole path to uniquely match a file to its external metadata. Is there anything special I need to do this, or is the path of the imported file simply preserved on import and easily accessible by the script?
Look up LrTransporter. I think it does what you want.