ExifTool Forum

ExifTool => Newbies => Topic started by: alegro on July 03, 2012, 04:03:34 PM

Title: Use of "IF" in a command
Post by: alegro on July 03, 2012, 04:03:34 PM
Lots of my Canon CR2 files have the tag "CameraOrientation: Rotate 90 CW" which causes progams like Irfanview to show them in portrait orientation. This can be a bit of a nuisance when I want to use these photo's for focus stacking. So I'm trying to change the value of this tag into "Horizontal (Normal)", which is the value for landscape orientation.

At first I tried "exiftool -cameraorientation='Horizontal (Normal)' image.cr2" but that resulted in:
'Can't convert TAG (not in PrintConv)'

It turned out I had to use: "exiftool -cameraorientation#=0 image.cr2" in order to get the right value.

Then I tried to use the command with the "if" option to only change the tag in files that don't already have "CameraOrientation Horizontal (Normal)" (or "CameraOrientation 0") but whatever I tried it didn't work. So my question is: how do I have to use exiftool to batch process portrait oriented ("rotated") files into landscape oriented ("horizontal") files?

Thanks in advance!
Arjan (from Holland)
Title: Re: Use of "IF" in a command
Post by: Phil Harvey on July 04, 2012, 07:43:54 AM
Hi Arjan,

I'm just stabbing in the dark with my answer here because I don't know what camera you are using, what system you are running on, or what ExifTool version you are using.

On my Mac, running ExifTool 8.96, on CR2 images from an EOS 600D, this command works:

exiftool -cameraorientation='Horizontal (Normal)' FILE

The -if option could look like this:  -if '$cameraorientation !~ /Horizontal/i'

Which is true if the CameraOrientation doesn't contain the word "horizontal" (case insensitive).  The above quoting is for Mac/Linux.  On Windows you must use double quotes.

- Phil
Title: Re: Use of "IF" in a command
Post by: alegro on July 05, 2012, 08:44:34 AM
Quote from: Phil Harvey on July 04, 2012, 07:43:54 AMThe above quoting is for Mac/Linux.  On Windows you must use double quotes.

Using double quotes did the trick on my Win7 machine! I must have missed something while reading the FAQ.
Oh well, that's why I'm a newbie, I guess.  ;) (Or just a little bit a lot Windows-centric...)
Thanks very much!

Greetings
Arjan