Understanding the -if EXPR

Started by awkilpatrick, April 28, 2015, 02:27:51 AM

Previous topic - Next topic

awkilpatrick

Hi,

I'm attempting to do something fairly straightforward ( I think ) and am running into a syntax issue. I can't seem to get the expression correct for what I want to do in an -if statement.

I have a tag that has contains a value that causes me trouble and would like to use an expression to skip using that tag.

The value tends to show up when processing a .mp3 Album value:

<Unknown encoding 84> IT2.

I've attempted just a simple exiftool statement to get the syntax correct but have had no luck.

exiftool -Year -if '$Album eq "<Unknown encoding 84> IT2."' ./some_title.mp3
1 files failed condition

What is the correct way to pattern match within the if expression? I simply want to look for any string that contains the <> symbols and then do something.

Thanks!

Phil Harvey

First, I assume you are on Mac or Linux, otherwise the quoting would be different.

It may be the "." that is messing you up.  ExifTool replaces control characters with a "." to avoid messing up the output, but your condition won't match a control character.  Instead, using a regular expression is probably the thing to do.  To just test for albums containing a less-than symbol, you could do this:

exiftool -year -if '$album =~ /</' FILE

Or you can put any other string between the slashes to match a substring in Album.  Google for "regular expressions" for more information.

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

awkilpatrick

Ahhh.

This is what I was missing;

$tag =~

I couldn't figure out the syntax to use a regular expression against a tag value. Thus the posting in the noob directory. I need to give your manual a better re-read.

THANK YOU for the prompt response.

Alan.