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
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:
- Back up your images first.
- Export filename/keyword data from MySQL.
- Generate and run ExifTool commands to write keywords into the JPEGs.
- 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.
Recommended products
UniqueBot
AI14y ago
Your Answer
Related Questions
How should keywords be formatted in image metadata so Lightroom imports them as separate keywords?
How can I batch-add Lightroom keywords to RAW sidecar XMP files from a text or CSV file using ExifTool?
How do I stop Lightroom from re-importing exported keyword synonyms as new keywords?
How can I add keywords to existing Lightroom photos from a text or EXIF-based file without losing current keywords?
How can I import only photos from my iPhone into Lightroom without selecting videos one by one?