# How to import metadata from .xmp sidecar files for .jpg, .tiff, and .png



## MichaelAdamKatz (Feb 8, 2012)

I have thousands of image files that I want to import into Lightroom. Some of the files are .nef, some are .jpg, .tiff, and other formats.

For each file, I have created (using an external program I wrote) a sidecar .xmp file with certain metadata keywords I want to associate with the file. (I determined the format to use for these .xmp files by doing some sample exports from lightroom, and I followed the format I saw in those .xmp files, but only included the keywords part of the metadata; I tried to attach to this post a sample .xmp file that I've written but this forum software seems to reject it; but in any case I don't *believe* that my problem is with the .xmp file format itself.)

If I have file1.nef and also have file1.xmp in the same directory, when I import file1.nef it automatically brings in the data from the file1.xmp sidecar, and the keywords appear associated with the photo as expected in Lightroom.

 But if I have file2.jpg and also file2.xmp in the same directory, when I import file2.xmp it does not bring in the metadata keywords in file2.xmp. I believe this is because Lightroom knows that certain formats such as .jpg can contain their own metadata, so it looks in the file instead of looking for a sidecar.

Is there any way (perhaps a setting at import time or a general Lightroom setting) to force it to take metadata from file2.xmp when I import file2.jpg? Ideally what I want is for it to take whatever keywords are already in the metadata embedded in the file, and to combine these with the keywords coming from the .xmp file.

I know that an alternative is to embed the desired keywords into the .jpg, .tiff and other files (leaving the .xmp files external for the .nef files) before doing the lightroom import. I know there are tools that do this, and I could possibly do it programmatically myself. However, I'd strongly prefer not to alter the original files in any way if I can avoid it. All I want to do is to get lightroom to associate some new (file-specific) keywords with the files I'm importing.

Finally, I think that yet another alternative might be to import the files into lightroom, and then programmatically add the additional keywords to the files programmatically using a lightroom (lua?) script. Not sure how viable that is.

Thanks for any help.

Michael


----------



## Mark Sirota (Feb 9, 2012)

Welcome to Lightroom Forums, and sorry your thread seems to have been missed.

You're right, there's no way to get LR to read XMP sidecars for files like JPEGs and TIFFs that can store the metadata themselves, and I understand your desire to avoid writing into the originals.

How about writing the XMP keywords into a copy of the files, then replacing the modified files with the originals afterwards?


----------



## MichaelAdamKatz (Feb 10, 2012)

Mark, thanks for the reply. That's a reasonable suggestion to do the file swap. Unfortunately, my methods of adding metadata to the .jpg files seems to be unreliable, due to some mysteries of the .net/.com libraries I'm using to do it. My new idea is that this is best done in a lightroom SDK lua script after the import: I just need to write a script that steps through the files in the catalog, reads in the external metadata files, and then there appear to be functions in the SDK to add the metadata to the files. I will report back on my success...

(Have to say I'm a bit surprised that this has become such a research project. I'm surprised it isn't a common request to bring in external files with custom/external metadata.)


----------



## LouieSherwin (Feb 10, 2012)

Hi Michael,

You might want to look at Phil Harvey's exiftool utility. I believe it will will allow you to copy any metadata between files with the same basename but having different extensions. .jpg and .xmp for example.

It will do it in batch mode and also leave you a backup or optionally edit the original in place. Sounds like you may be up to using this from the command line which is what you would have to do for your task.

-louie

http://www.sno.phy.queensu.ca/~phil/exiftool


----------

