How to get multiple -if with -execute and -progress, but no -dummy output after

Started by filigranen, January 10, 2021, 07:16:52 PM

Previous topic - Next topic

filigranen

Hi!

Apologies if this has been asked before, I searched and found alot of answers to other questions I had, but not the answer to this one unfortunately.

Short question (hard to formulate, hence the long question.  :) ): what would a line look like that only outputs the -progress and any tag outputs or echoes from each -if -execute part, without a -dummy summary at the end with a long list of files?

Long question:

I'm running a line like this one:

exiftool -if '$test1 eq "test1"' -echo 'Inside first if...' '-someTag<someTag' -execute -if '$test2 eq "test2"' -echo 'Inside second if...' '-someTag<anotherTag' -execute -common_args -progress *.jpg

which results in this output:

Inside first if...
    5 files failed condition
Inside second if...
    5 files failed condition
======== testimage2.jpg [1/5]
ExifTool Version Number         : 12.00
Now                             : 2021:01:11 00:41:43+01:00
[...snip...]
======== testimage3.jpg [2/5]
ExifTool Version Number         : 12.00
[...snip...]
    5 image files read

etc etc.

In other words, first my two tests, then a list of the files processed and all their info, since -common_args does not contain a tag to read.

I read in some thread about -dummy, so I added that like so:

exiftool -if '$test1 eq "test1"' -echo 'Inside first if...' '-someTag<someTag' -execute -if '$test2 eq "test2"' -echo 'Inside second if...' '-someTag<anotherTag' -execute -common_args -dummy -progress *.jpg

This is better, but it yields this output:

Inside first if...
    5 files failed condition
Inside second if...
    5 files failed condition
======== testimage2.jpg [1/5]
======== testimage3.jpg [2/5]
======== testimage4.jpg [3/5]
======== testimage5.jpg [4/5]
======== testimage.jpg [5/5]
    5 image files read

Again, the list of files after (which gets long if working with 1000+ files at the same time).

Is there any way to get rid of that last part, while using -progress and -common_args?

I tried adding all the common_args to each if, like so:

exiftool -if '$test1 eq "test1"' -echo 'Inside first if...' '-someTag<someTag' -P -wm w -fileorder filename -dummy -progress *.jpg -execute -if '$test2 eq "test2"' -echo 'Inside second if...' '-sometag<anotherTag' -P -wm w -fileorder filename -dummy -progress *.jpg -execute

and that yields the desired results:

Inside first if...
    5 files failed condition
Inside second if...
    5 files failed condition

but with all that exiftool can do, it seems odd I should have to use this horrible and hard to maintain code to get my way. Add a few more -if's and I will get lost fast.

Luuk2005

Greetings Filigranen.. This very hard to understand, so Im just saying what is noticed.
Im also thinking if you make the output exactly how its to be desired, both when matching and not-matching, maybe the experts can better help?

Most commands is having an extra -execute to be removed, this maybe why -dummy is helping???  So to be more like...
exiftool -if 'Condition1' -DoSomething1 -echo 'Condition1' -execute  -if 'Condition2' -DoSomething2 -echo 'Condition2' -common_args -AllTheCommonArgs

Edit: Fixed the double-quotes to single-quotes
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

Phil Harvey

I still don't know what you want.  This long explanation didn't help.  Could you just show an example of the output you want and I'll tell you if it is possible.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

I think you want to do is remove that last -execute. Execution of the command line does not stop at the -Common_Args option and continues until the end of the command.  So when you have -execute -common_args, that means run exiftool again with only the common args, which would output all the data for all the files.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

filigranen

Quote from: Phil Harvey on January 11, 2021, 07:42:18 AM
I still don't know what you want.  This long explanation didn't help.  Could you just show an example of the output you want and I'll tell you if it is possible.

- Phil

The desired output is the one at the bottom, and using StarGeeks suggestion to remove the last -execute it works just as I want it to:

[arch] ~/test
(22:25) $ exiftool -if '$test1 eq "test1"' -echo 'first if' -filename -execute -if '$test2 eq "test2"' -echo 'second if' -datetimeoriginal -common_args -progress *.jpg
first if
    5 files failed condition
second if
    5 files failed condition
[arch] ~/test
(22:25) $


So simple.

I thought it was

exiftool -if something -execute -if another if -execute -if third if -execute -common_args -whatever DIR/FILE

in other words, each if followed by an execute to run it. And then -common_args.

I read the manpage, and the bold part tricked me:
Quote
-execute[NUM]
            Execute command for all arguments up to this point on the command line (plus any arguments
            specified by -common_args).
           [...snip...]

I thought it meant, "from the -if part and up to the next -execute", and each if needed an execute in a multiple if statement. But, obiously, the last -if is executed anyway.
I do find it odd however that the last -execute would run it all "empty", with just the -common_args. The last -execute might be superflous, but the output should be the same. But that's just my opinion ofc. Now I know how it works.

Thanks alot for your help, and the quick replies!

Btw, is there a way to mark the thread solved? Just update the title?

StarGeek

Quote from: filigranen on January 11, 2021, 04:44:03 PMBtw, is there a way to mark the thread solved? Just update the title?

You can do that if you want.  We're pretty casual about things here and usually don't worry about it.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).