How to batch edit a value: "if value=x then change it".

Started by wingchun, September 02, 2012, 11:10:38 PM

Previous topic - Next topic

wingchun

I want to change -Exif:LensModel="50mm F1.4" into -Exif:LensModel="Sigma AF 50mm F1.4 EX DG HSM", but the jpgs with this value are spread into different folders and mixed with jpegs shot with other lenses.
Is there a way to launch exiftool in a way that changes the value in some folders and subfolders only if it corresponds to "50mm F1.4", leaving all other jpgs untouched?
Thanks in advance.

Phil Harvey

Yes.

exiftool -if "-exif:lensmodel eq '50mm F1.4'" -exif:lensmodel="Sigma AF 50mm F1.4 EX DG HSM" -r DIR

(where DIR is the name of the root directory containing your images)

Note that this will preserve the original images by adding "_original" to the extension of the file.  Afterwards, if you realize you did something wrong, you can restore the originals:

exiftool -restore_original -r DIR

or delete the originals if you don't want them:

exiftool -delete_original -r DIR

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