How can I batch-add keywords to JPEG files from a database before importing into Lightroom?

Asked 10/10/2011

4 views

2 answers

0

I have about 30,000 JPEG images in a single folder, each with a unique numeric filename such as 123456789.jpg. The keywords for each image already exist in a MySQL database, and I can export that data in whatever format is needed.

My goal is to get the keywords attached to the correct JPEG files so Lightroom can read them during import. I know Lightroom can import keyword lists from text files, but that does not automatically match keywords to specific filenames.

What is a practical way to batch-write keywords into the JPEG metadata by matching each filename to its keyword list from the database before importing into Lightroom?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

14y ago

2 Answers

1

You could export the tags as a batch script that runs exiftool to add the keywords to the JPEG files:

exiftool -keywords+=banana 111.jpg
exiftool -keywords+=fruit 111.jpg
exiftool -keywords+=tree 112.jpg
...

with a query resembling this:

select concat('exiftool -keywords+=',KEYWORD,' ',FILE_NUMBER,'.jpg') from IMAGE

and then

  • backup your images
  • run the generated batch script
  • import the images into Lightroom

Originally by user4390. Source · Licensed CC BY-SA 4.0

user4390

14y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

A practical workflow is to write the keywords into each JPEG’s metadata first, then import the files into Lightroom.

One straightforward way is to use ExifTool. Export your MySQL data in a form that pairs each filename with its keywords, then generate commands such as:

exiftool -keywords+=banana 111.jpg exiftool -keywords+=fruit 111.jpg exiftool -keywords+=tree 112.jpg

You can generate those commands directly from MySQL with a query that concatenates the filename and keyword into ExifTool command lines, save the result as a batch/script file, then run it on your image folder.

Suggested process:

  1. Back up your images first.
  2. Export filename/keyword data from MySQL.
  3. Generate and run ExifTool commands to write keywords into the JPEGs.
  4. Import the JPEGs into Lightroom; Lightroom should read the embedded metadata.

This approach works because Lightroom can read keywords already stored in the image metadata, while a plain keyword list import does not automatically match keywords to specific files.

UniqueBot

AI

14y ago

Your Answer