ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: axel.hennig on February 08, 2019, 05:59:11 AM

Title: -if combined with -directory does not what I think it should do
Post by: axel.hennig on February 08, 2019, 05:59:11 AM
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 (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
Title: Re: -if combined with -directory does not what I think it should do
Post by: Stephen Marsh on February 08, 2019, 07:24:19 AM
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!
Title: Re: -if combined with -directory does not what I think it should do
Post by: axel.hennig on February 08, 2019, 07:33:38 AM
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.
Title: Re: -if combined with -directory does not what I think it should do
Post by: Stephen Marsh on February 08, 2019, 08:06:45 AM
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"
Title: Re: -if combined with -directory does not what I think it should do
Post by: axel.hennig on February 08, 2019, 08:18:24 AM
Hi Stephen Marsh,

thanks a lot. This works great.

Regards,
Axel
Title: Re: -if combined with -directory does not what I think it should do
Post by: Stephen Marsh on February 08, 2019, 08:19:31 AM
My pleasure Axel!

But to be clear, which one worked? The first, second or both?
Title: Re: -if combined with -directory does not what I think it should do
Post by: axel.hennig on February 08, 2019, 08:57:40 AM
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.