ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: mulu on March 27, 2020, 12:24:07 PM

Title: Multiple If & No file specified
Post by: mulu on March 27, 2020, 12:24:07 PM
I read some threads about multiple if statements but I can't get it to work. Here is what I have:

"exiftool(-k).exe"

-config acdsee-rs.config

-if "defined $RegionInfoACDSeeAppliedToDimensionsw and $orientation=~/Rotate 270 CW|Rotate 90 CW/ and RegionInfoACDSeeAppliedToDimensionsw neq ImageHeight" "-RegionInfoACDSeeAppliedToDimensionsw<ImageHeight" "-RegionInfoACDSeeAppliedToDimensionsh<ImageWidth" -execute

-if "defined $RegionInfoACDSeeAppliedToDimensionsw and not $orientation=~/Rotate 270 CW|Rotate 90 CW/ and RegionInfoACDSeeAppliedToDimensionsw neq ImageWidth" "-RegionInfoACDSeeAppliedToDimensionsw<ImageWidth" "-RegionInfoACDSeeAppliedToDimensionsh<ImageHeight"

-r -P -overwrite_original_in_place "C:\temp\myimage.jpg"

This returns
No file specified
   1 image files updated

It's actually a conflicting message. On hand it says that no file was specified but then it also says 1 image file was updated. Note, the separation on multiple lines is just for this post so it's easier to see what I am doing. In reality this is one single, long line.
Title: Re: Multiple If & No file specified
Post by: StarGeek on March 27, 2020, 12:52:37 PM
Quote from: mulu on March 27, 2020, 12:24:07 PM
It's actually a conflicting message. On hand it says that no file was specified but then it also says 1 image file was updated.

No, it's not conflicting.  See the docs on the -execute option (https://exiftool.org/exiftool_pod.html#execute-NUM).  Your command breaks down like this.

exiftool(-k).exe -config acdsee-rs.config -if "defined $RegionInfoACDSeeAppliedToDimensionsw and $orientation=~/Rotate 270 CW|Rotate 90 CW/ and RegionInfoACDSeeAppliedToDimensionsw neq ImageHeight" "-RegionInfoACDSeeAppliedToDimensionsw<ImageHeight" "-RegionInfoACDSeeAppliedToDimensionsh<ImageWidth"

Then the -execute starts a new command. Note that there is no filename in that part of the command.

exiftool(-k).exe -config acdsee-rs.config -if "defined $RegionInfoACDSeeAppliedToDimensionsw and not $orientation=~/Rotate 270 CW|Rotate 90 CW/ and RegionInfoACDSeeAppliedToDimensionsw neq ImageWidth" -RegionInfoACDSeeAppliedToDimensionsw<ImageWidth" "-RegionInfoACDSeeAppliedToDimensionsh<ImageHeight" -r -P -overwrite_original_in_place "C:\temp\myimage.jpg"

The -config option (https://exiftool.org/exiftool_pod.html#config-CFGFILE) carries over (see the docs linked) but nothing else does.  The first command does not have access to the -r -P -overwrite_original_in_place "C:\temp\myimage.jpg"

You need to add the -Common_Args option (https://exiftool.org/exiftool_pod.html#common_args) option at the end
-Common_Args -r -P -overwrite_original_in_place "C:\temp\myimage.jpg"
Title: Re: Multiple If & No file specified
Post by: mulu on March 27, 2020, 05:02:04 PM
@StarGeek, ahh I thought -Common_Args is a place holder(!) for the common arguments. Instead, this is a keyword/option after which common arguments follow. I should have realized this since it's written as -Common_Args and not something like [Common_Args]. Thanks a lot!