Author Topic: Use of "IF" in a command  (Read 2513 times)

alegro

  • Newbie
  • *
  • Posts: 2
Use of "IF" in a command
« 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)

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Use of "IF" in a command
« Reply #1 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

alegro

  • Newbie
  • *
  • Posts: 2
Re: Use of "IF" in a command
« Reply #2 on: July 05, 2012, 08:44:34 AM »
The 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
« Last Edit: July 05, 2012, 09:11:18 AM by alegro »