Cleaning up unknown lens types in CRW files with "-if"

Started by jwsteel, June 10, 2013, 11:18:54 AM

Previous topic - Next topic

jwsteel

Hi all,

I've been trying to clean up my mess of a photo library and get everything all nice and tagged, and I've had a lot of success with ExifTool so far. Thanks, Phil!

My old camera, the original Digital Rebel, wasn't capable of recording the actual lens info; it just wrote out "Unknown (-1)" for LensType (but did record the focal length). This results in things like "50.0 mm" under the Lens information, and I've manually been able to change it up so that it reads correctly in Lightroom, etc. by using the following command:

exiftool -n -LensType=198 -Lens='Canon EF 50mm f/1.4 USM' FILE

Where I'm running into issues now is that I'm encountering some directories of files where I switched up lenses during the course of the shoot, and I'd like to be able to use the conditional -if to scan the directory and make the appropriate changes. Would something like this work?

exiftool -n -if "$Lens eq '50.0 mm'" -LensType=198 -Lens='Canon EF 50mm f/1.4 USM' -execute -if "$Lens eq '17.0-55.0 mm'" -LensType=240 -Lens='Canon EF-S 17-55mm f/2.8 IS USM' -common_args -progress DIR


Thanks for any advice!

Best,
Jeff

Phil Harvey

Hi Jeff,

Looks good.  (on Windows anyway.  On Mac/Linux you would need different quotes)

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

jwsteel

Thanks, Phil!

How would I change the quotes for Mac? Would it then be:

... -if '$Lens eq "50.0 mm"' ...

Thanks,
Jeff

Phil Harvey

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

jwsteel


jwsteel

Actually, I ran into a snag, but I figured out the solution for it.

Since $Lens is a composite tag, the -if was failing, no matter what value I tried. So, I dug into the tag definitions, and saw that it was derived from the minimum and maximum focal length values. This led to the following:

...-if '$Canon:MinFocalLength eq "50"'...

That worked just fine!

Thanks,
Jeff