Project

General

Profile

Can exiv2 output exif data to a text file?

Added by Michal K about 11 years ago

First question, this command:

exiv2 -p v pr image.NEF

outputs information to the console. I didn't find an option to output to a file - is it possible to do it? I know how to output to an .exv file, but I want just plain text file formatted with -p parameter.

Also, another question about the -g grep option because I don't understand what grep really means. Can I use it to match multiple exif keys? I'l like to use a wildcard or a regular expression but none seem to work. For example something like this:

exiv2 -p v -g Exif.Nikon3.* image.NEF


Replies (4)

RE: Can exiv2 output exif data to a text file? - Added by Andreas Huggel about 11 years ago

On Linux I do

$ exiv2 -pv image.NEF > image.txt

do redirect the standard output to a file. I'm not sure if this works exactly the same on stock Windows. It does on my Windows box which has MSYS/MinGW.

The -g option requires a complete key. There is no support for regular expressions or wildcards (although that would be a nice feature). You can pass multiple -g options to the command line. Again, on Linux (or Windows with a grep command), I'd use regular grep to filter just the Nikon3 tags:

$ exiv2 -pv image.NEF | grep Exif.Nikon3 > image.txt

Andreas

RE: Can exiv2 output exif data to a text file? - Added by Michal K about 11 years ago

Thanks for the explanation, it's all clear now!

RE: Can exiv2 output exif data to a text file? - Added by Steve Wright about 11 years ago

If I just want the value of a particular tag, output to a text file, I use the "-g" option this way

>> exiv2 -g Exif.Image.UserComment -Pv someimage.jpg >imageinfo.txt

In Linux and Cygwin you can script this command for more than one tag, and use double-right-carat [ >> ] to add to the same text file once it's written.
Of course, if you want just the EXIF data, with tag names, there's also
>> exiv2 -Pkyst myimage.jpg | grep Exif>>image.txt

This gives you the same columns and info as a "-pa image.jpg" would, but only the EXIF-tag lines print out.
Andreas: I had to look back on the man page to find those, and "shoot a few down" that gave more info than was necessary. I'd seen it on an edit of the manpage, but on the one I had downloaded (or exported from some L/Unix build, I forget which now) it was missing. Imagine that. :)

Steve Wright

RE: Can exiv2 output exif data to a text file? - Added by Andreas Huggel about 11 years ago

Steve,

Try to keep the exiv2 command line tool binary and man page in sync. They belong together and I make an effort to update the manpage for every change in the tool. Thus the -P switches have been documented in the man page ever since they were born.

For quick reference you can always run

$ exiv2 -h

which writes out a summary of the command line options. It also lists the available -P toggles.

Andreas

    (1-4/4)