Conditional -if to use “contains” rather than “equals”?

Started by Stephen Marsh, April 04, 2018, 09:10:39 PM

Previous topic - Next topic

StarGeek

It matters when you are using -execute.  It's more in the details of -execute and -common_args than it is an effect of -r.  When you use -execute, the command only accounts for any options up until that point.  After the -execute, it's an entirely new command and will not use any options from before the -execute.  That's why if you are using an -execute option and want to recurse through all commands, you need to put the -r after a -common_args, so it is common to all of the commands.

Here's a simple example, where the -r is right at the start of the command.  Notice how there is no recursion after the -execute.

C:\>exiftool -echo "Before Execute" -r -filename  Y:\!temp\y -execute -echo "After Execute" -filename  Y:\!temp\y
Before Execute
======== Y:/!temp/y/Test1/Img01.jpg
File Name                       : Img01.jpg
======== Y:/!temp/y/Test2/Img01.jpg
File Name                       : Img01.jpg
======== Y:/!temp/y/Test3/Img01.jpg
File Name                       : Img01.jpg
    4 directories scanned
    3 image files read
After Execute
    1 directories scanned
    0 image files read
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Stephen Marsh

Thank you StarGeek.

So even if this is the only exception to the "rule" for recursive scans, I "can't go wrong" if I just add -r command as the last argument before DIR, whether or not I am using -execute and -common_args. I'm just trying to come up with a fool proof way to use recursive scanning without having to remember the exceptions and edge cases where it does matter.

So both of these should be equivalent commands if I understand you correctly:

exiftool -if '$HasRealMergedData eq "No"' -directory=%d'Max Compatibility Off' -execute -if '$AlphaChannelsNames =~ /Transparency/' -directory=%d'Transparent Images' -common_args -r DIR

vs.

exiftool -r -if '$HasRealMergedData eq "No"' -directory=%d'Max Compatibility Off' -execute -r -if '$AlphaChannelsNames =~ /Transparency/' -directory=%d'Transparent Images' -common_args DIR

Notice the use of 2 -r commands in the second example.

Phil Harvey

Quote from: Stephen Marsh on April 10, 2018, 11:58:22 PM
I "can't go wrong" if I just add -r command as the last argument before DIR

Correct.

QuoteSo both of these should be equivalent commands if I understand you correctly:

Yes.

- 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 ($).

Stephen Marsh