-if combined with -directory does not what I think it should do

Started by axel.hennig, February 08, 2019, 05:59:11 AM

Previous topic - Next topic

axel.hennig

Hi

I've got a problem with -if and -directory

The following works (code + output):


N:\>exiftool.exe -validate -warning -error -a bad.jpg
Validate                        : 4 Warnings (3 minor)
Warning                         : [minor] Unknown APP4 segment
Warning                         : Missing required JPEG ExifIFD tag 0x9101 ComponentsConfiguration
Warning                         : [minor] IFD0 tag 0x0100 ImageWidth is not allowed in JPEG
Warning                         : [minor] IFD0 tag 0x0101 ImageHeight is not allowed in JPEG


But the following does not work (means the image file is not moved to the 'error' directory. I got this line of code from https://exiftool.org/forum/index.php?topic=5527.0.


N:\>exiftool.exe -if "$warning or error" -directory=error bad.jpg
    1 files failed condition


I'm working with Windows.

Any help would be great.

Thanks,
Axel

Stephen Marsh

#1
If I just try the following:

exiftool -warning FILE

or

exiftool -error FILE

Then nothing happens... however I don't have a "bad" file to test against.

If I just try this:

exiftool -validate FILE

Validate : OK

Then it works fine by itself.

So the following worked:

exiftool -directory="C:\Users\username\Desktop\Pass" -if "$validate eq 'OK'" "C:\Users\username\Desktop\Test Image.jpg"

Therefore to do the opposite:

exiftool -if "not $validate eq 'OK'" -directory="C:\Users\username\Desktop\Fail" "C:\Users\username\Desktop\Test Image.jpg"

Hope this helps!

axel.hennig

Hi Stephen Marsh,

thanks for your suggestion.

When I run your code I get:


N:\>exiftool.exe -if "$warning" -directory=error -execute -if "$error" -directory=error bad.jpg
No file specified
    1 files failed condition


And when I run the following, I get:


N:\>exiftool.exe -if "$warning" -directory=error bad.jpg -execute -if "$error" -directory=error bad.jpg
    1 files failed condition
    1 files failed condition


So thanks again, but this doesn't solve the problem.

Stephen Marsh

You will see that I changed my original reply with different code, removing the original code that you quote... However if you are using my original code, then it should have the following added after linking the two if conditions with the -execute command:

-common_args

As in:

exiftool.exe -if "$warning" -directory=error -execute -if "$error" -directory=error -common_args bad.jpg

So I am still curious if the following works:

exiftool -if "not $validate eq 'OK'" -directory="C:\Users\username\Desktop\Fail" "C:\Users\username\Desktop\Test Image.jpg"

axel.hennig

Hi Stephen Marsh,

thanks a lot. This works great.

Regards,
Axel

Stephen Marsh

My pleasure Axel!

But to be clear, which one worked? The first, second or both?

axel.hennig

I just tried

exiftool -if "not $validate eq 'OK'" -directory="C:\Users\username\Desktop\Fail" "C:\Users\username\Desktop\Test Image.jpg"

and this worked. Didn't check the other code-lines.