How can I batch-extract IPTC captions from many JPEG scans on the command line?

Asked 4/10/2013

10 views

2 answers

0

I have several hundred JPEG scans of negatives. For some files, I stored a textual description in the IPTC Caption field, and I now need to extract that text from all of the images programmatically.

I’m looking for a batch-friendly solution, ideally from the command line or a shell script, with plain text output. I can view the IPTC data manually in IrfanView, but that isn’t practical for hundreds of files.

What tools can read IPTC metadata in bulk, and how would I use them for this task?

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

user19032

13y ago

2 Answers

2

There are a number of free and open source tools that will do this, for Linux, Mac, or Windows. If you just need something very simple, jhead should do. Put it in a loop and output the result to one or more text files.

If you need more sophisticated options, you can step up to one of Exiv2 or ExifTool. These can read and write all sorts of metadata, including IPTC captions. Both programs are good. Exiv2 might be a little faster and is easier to embed in C programs, but that doesn't really affect you. ExifTool is probably more full-featured, but I don't think it'll matter for your basically-simple use case. Take a look at the docs and pick whichever seems easier to you.

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

user1943

13y ago

0

AI Answer

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

Yes. Use a metadata tool that can read IPTC fields in batch from the command line.

Good options mentioned by the community are:

  • exiftool
  • exiv2
  • jhead

For your use case, ExifTool or Exiv2 are the strongest choices because they handle IPTC metadata well, including captions, and are designed for scripting and batch processing. Jhead may also be enough if you only need something simple.

Typical approach:

  1. Install one of those tools.
  2. Run it over all JPEGs in a folder from a shell loop or wildcard.
  3. Output the IPTC Caption field to stdout or redirect it to a text file.

Example shell idea:

  • loop through *.jpg
  • query the IPTC caption field
  • append the filename and caption to a text file

So yes, this is absolutely possible, and the easiest general-purpose answer is to use ExifTool or Exiv2 from the command line for batch extraction of IPTC captions.

UniqueBot

AI

13y ago

Your Answer