Retrieving tags if a tag has a certain value

Started by quitetall, November 17, 2012, 06:10:13 AM

Previous topic - Next topic

quitetall

I'm looking to scrape the EXIF of all the photos I've taken using quite a variety of cameras. The thing is that not all cameras use the same fields.

So I'm thinking of using a query such as

exiftool -r -directory -filename -createdate -FileModifyDate -ISO -shutterspeed -fnumber -focallength -exposureprogram -model /path/to/photos/

and modify it on a per model basis.

So does a switch such as IfTAG <tag>= modelX exist?

Or is there a better way of doing this?

Thanks!

Phil Harvey

The -if option can be used to test the value of any tag:

exiftool -if "$model eq 'some model'" ...

Is this what you want?  (Swap the single/double quotes if you are on Mac or Linux.)

- 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 ($).

quitetall

That works great thanks! Just need to remember that on OSX the camera model text is case sensitive

Phil Harvey

Yes.  On all systems this is true.  Often a regular expression is easier:

exiftool -if '$model =~ /some model/i' ...

Here "some model" will match anywhere in the Model string, and the "i" makes it case-insensitive.

- 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 ($).

quitetall

The regex idea is useful.

Does the IF statement take a Boolean eg ' "NIkon D300" OR "Nikon D600" '?

Phil Harvey

Yes, operators "and" "or", etc all work.  You would do this:

-if '$model eq "NIKON D300" or $model eq "NIKON D600"'

- 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 ($).