How to (Batch) embed XMP data — Sidecars into same-named JPEGs?

Started by soulbot, December 20, 2012, 06:13:22 PM

Previous topic - Next topic

soulbot

Hello,

As this is my first post here, I hope I'm posting this in the proper forum. I was poking around already trying to find the answer to my question, before posting, but didn't come across anything quite as specific as what I'm hoping to achieve. I feel certain that the answer is out there though.

I'm about to embark on the process of migrating my entire Aperture catalog over to Lightroom. I'm doing some small test runs first to discover what kind of hiccups to expect. The Raw files involved aren't going to be an issue. I am going to use the Anon Arts Lightbox pluging for this. It will let me write sidecar files (only) for all the adjusted, keyworded Raws. Since most apps, including Lightroom, ignore XMP sidecars for JPEGs, it's now the JPEGs that become the concern.

Here's what I'm hoping to do with the JPEGs in the collection: export Masters from Aperture into a temporary holding zone. I'll choose to include IPTC4XMP sidecars to hang onto the keywords and ratings. But now I'll need to merge all the XMP data into the respective JPEG masters. Of course it makes sense to do this once, in a batch. I've already played around with the tagsfromfile command in a single file test. In that scenario I simply used the command—

exiftool -tagsfromfile my_photo.xmp my_photo.jpg

Works perfect for a writing the metadata from the .xmp file into the JPEG. Here then are my questions:

1.) How will the command differ when trying to run on many files? The JPEGs will all have a same-name XMP file, residing right beside them.

2.) Can the batch run on subfolders? Aperture is going to re-create my original project structure. The result will be a folder, with subfolders and the JPEGs will reside in the subfolders. Can the exiftool command somehow drill down into all these subfolders and still handle the mating up? Or will I need to break everything out into a single pool with all photos and all .xmp? How do I feed exiftool with directories?

3.) When embedding the metadata into the JPEGs can I (should I) only embed the rating and keywords? After all, that's all I'm looking to be able to use over in Lightroom anyway...

Any advice would be greatly appreciated.


Phil Harvey

Hi,

Yes, ExifTool can certainly do what you want.

Quoteexiftool -tagsfromfile my_photo.xmp my_photo.jpg

Works perfect for a writing the metadata from the .xmp file into the JPEG.

I would suggest a slight change if you want the XMP to stay as XMP (otherwise, same-named tags would be written to EXIF or IPTC instead of XMP):

exiftool -tagsfromfile my_photo.xmp -xmp:all my_photo.jpg

Quote1.) How will the command differ when trying to run on many files? The JPEGs will all have a same-name XMP file, residing right beside them.

The only difference that you specify a directory name instead of a file name.  But in this case you should add a -ext option to process only the JPEG files:

exiftool -tagsfromfile my_photo.xmp -xmp:all -ext jpg my_directory

Quote2.) Can the batch run on subfolders?

Just add the -r option to the above command and it will process files in the directory then recurse into sub-directories.

Quote3.) When embedding the metadata into the JPEGs can I (should I) only embed the rating and keywords? After all, that's all I'm looking to be able to use over in Lightroom anyway...

You can easily do this by specifying -xmp:rating -xmp:subject instead of -xmp:all in the command.  It is up to you to decide how much (or little) of the metadata you want to copy.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

soulbot

Hi Phil,

Thanks so much for the straightforward input. It works quite well!

However, the part I suppose I'm not following exactly is how to get the batch to use the 2nd .xmp for the 2nd jpeg, 3rd xmp. :: 3rd jpg, etc...

As it stands now, the metadata (rating, keywords) from, let's call it,  image_001.xmp is being embedded into image_001.jpg. Perfect! However since image_001.xmp is the sole .XMP file being called on by the command, only its metadata is being copied into ALL the jpegs. I'm hoping to have image_001.xmp metadata copy into image_001.jpg, but then

image_002.xmp metadata copy into image_002.jpg
image_003.xmp metadata copy into image_003.jpg
image_004.xmp metadata copy into image_004.jpg

...somehow I'm missing how to get this critical same-name alignment scenario to sync up and ripple throughout all the files properly.

For simplicity I'm using the simplest possible catalogs for experimenting. But I'll attach a screenshot showing my file structure. Pointing the command to the root of the folder, to "find" the JPEGs was simple enough. But by dropping a single .XMP file into the xmp slot in the terminal command, I'm marrying only it's metadata into ALL resulting jpegs. I'm sure I'm missing something simple.

Thanks again for your patience with a newbie!  :D
—Kevin


Phil Harvey

Hi Kevin,

Sorry, my mistake.  I wasn't paying close enough attention to the command.  To copy metadata from the same-named files it should have been:

exiftool -tagsfromfile %d%f.xmp -xmp:all -ext jpg -r my_directory

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

soulbot

Awesome! This works perfectly.

Thanks so much for your guidance, Phil!

Happy Holidays

kittehluvzburgr

Sorry for necroposting :)

I have the same question / situation.

Have a whole heap (around 6500) of jpg / jpeg files, with obsolete tags inside, and a sidecar xmp files, with new, valid tags.

Like

1a7ffb0fee399c2f026458c04072c2b53b9d5362_m.jpg
1a7ffb0fee399c2f026458c04072c2b53b9d5362_m.xmp
1ad8561a24708b940617f37fc8637b26.jpg
1ad8561a24708b940617f37fc8637b26.xmp
1ALX0461.jpg
1ALX0461.xmp
1b2ghgpaipg81.jpg
1b2ghgpaipg81.xmp

And so on.

Ok, i can batch delete all metadata info from image files.

But how can i batch transfer tags from xmp files into jpg / jpeg?

I tried comand from post above and it didn't work for me.

exiftool -tagsfromfile %d%f.xmp -xmp:all -ext jpg -r g:\1\

Always get a "File 'f.xmp' does not exist for -tagsFromFile option" error.

Any sugestions?

Thanks in advance!

Environment:
Win10 Pro
exiftool-12.41

StarGeek

Since the %d% part is disappearing, this is most likely FAQ #27 (or see the .sig on this post).
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

kittehluvzburgr

Hi StarGeek

Thanks for the reply!
Changed that %% part and it works great!

Thanks!

MtnBiker

`exiftool -tagsfromfile %d%f.xmp -xmp:all -ext jpg -r my_directory`

doesn't work for Keywords, only the first is copied over.

`exiftool -tagsfromfile 'image.xmp' -all:all 'image.rw2'`

does work for a single file.

Maybe I'll be able to sort this out.

Phil Harvey

If the second command doesn't copy all keywords it is because they aren't all stored in XMP.  The first command copies all XMP, while the second copies all tags.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

MtnBiker

My bad. I must have gotten mixed up with all the trials I was doing.

Great that this works so well and simple to do.

Thank you for continuing to support this fantastic resource.