ExifTool Forum

ExifTool => Newbies => Topic started by: quitetall on November 17, 2012, 06:10:13 AM

Title: Retrieving tags if a tag has a certain value
Post by: quitetall on November 17, 2012, 06:10:13 AM
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!
Title: Re: Retrieving tags if a tag has a certain value
Post by: Phil Harvey on November 17, 2012, 08:04:19 AM
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
Title: Re: Retrieving tags if a tag has a certain value
Post by: quitetall on November 18, 2012, 05:53:49 AM
That works great thanks! Just need to remember that on OSX the camera model text is case sensitive
Title: Re: Retrieving tags if a tag has a certain value
Post by: Phil Harvey on November 18, 2012, 10:29:05 AM
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
Title: Re: Retrieving tags if a tag has a certain value
Post by: quitetall on November 19, 2012, 05:06:29 PM
The regex idea is useful.

Does the IF statement take a Boolean eg ' "NIkon D300" OR "Nikon D600" '?
Title: Re: Retrieving tags if a tag has a certain value
Post by: Phil Harvey on November 19, 2012, 09:04:16 PM
Yes, operators "and" "or", etc all work.  You would do this:

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

- Phil