ExifTool Forum

ExifTool => Newbies => Topic started by: Geoff_12889 on July 26, 2023, 04:04:14 PM

Title: How to check if a value matches
Post by: Geoff_12889 on July 26, 2023, 04:04:14 PM
How would I go about checking if a value matches?

My use case is I want to check if "-Make" == "FUJIFILM".

My little understanding would be something like:

-exiftool [path] -Make == FUJIFILM
Title: Re: How to check if a value matches
Post by: Phil Harvey on July 26, 2023, 04:07:02 PM
Try this:

exiftool -filename -if "$make =~ /FUJIFILM/i" FILE

The comparison above will match "FUJIFILM" anywhere in the Make value, ignoring case.  And print the file name if it matches.

- Phil
Title: Re: How to check if a value matches
Post by: Geoff_12889 on July 26, 2023, 04:19:39 PM
Quote from: Phil Harvey on July 26, 2023, 04:07:02 PMTry this:

exiftool -filename -if "$make =~ /FUJIFILM/i" FILE

The comparison above will match "FUJIFILM" anywhere in the Make value, ignoring case.  And print the file name if it matches.

- Phil

I tried that option and get the following:

Error: File not found - FILE
You were meant to enter any valid file name, not "FILE" literally.
    1 files failed condition
    0 image files read
    1 files could not be read

I tried removing "FILE" from the end and get this result:

1 files failed condition
But it should match.
Title: Re: How to check if a value matches
Post by: Geoff_12889 on July 26, 2023, 06:03:01 PM
I'm on Mac so I needed to use single quotes. It seems to be working.

How would I have it return 'true' instead of the file name?
Title: Re: How to check if a value matches
Post by: Phil Harvey on July 26, 2023, 08:35:03 PM
Yes.  My signature tells about the quoting.  I assume Windows unless told otherwise.

The exit status will be 0 on success, or 2 if the file failed the condition.

- Phil