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 :)
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
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
Thank you both - I tried Phil's and it was perfect for my needs.