Finding a string within a tag

Started by lclarke522, June 01, 2015, 08:19:45 PM

Previous topic - Next topic

lclarke522

Hi! I am trying to change the titles of a batch of images so that it reflects the camera maker, model, and lens. However, in some cases the camera maker is already a part of the value stored in the model tag and I don't want to display that twice. 

I'm having trouble with the syntax of "if $model begins with $make then..."

I doesn't have to be "begins with." I'd be satisfied with "contains."

Thanks in advance  :)

Hayo Baan

I think you are looking for the following regular expression for your -if: $model =~ /^$make/
This will match only when model starts with make. If you want to match case insensitive, add an i after the last /. To negate the match, use !~ instead of =~.

Hope this helps,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Alternatively, maybe you could strip the Make from the Model when copying, something like this:

exiftool "-title<${Make} ${Model;s/\s*$$self{VALUE}{Make}\s*//i} ${LensID}" -m FILE

Here I am taking advantage of the undocumented ExifTool internals to access the Make tag from within the advanced formatting expression for Model.  But a disadvantage of doing it this way is that you will get a warning due to an uninitialized value in this expression if Make doesn't exist.

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

lclarke522

Thank you both - I tried Phil's and it was perfect for my needs.