Main Menu

-IF in a ARG-File

Started by Quant007, July 08, 2020, 05:20:33 AM

Previous topic - Next topic

Quant007

Hallo,
in my ARG-File I have this code for testing:

-FileName<$QuickTime:CreateDate.%le
-d
%Y-%m-%d_%H-%M-%S%%-c
-if (($title) and ($datetimeoriginal))
-FileName<$QuickTime:CreateDate-${title;tr/ /_/}.%le

In the file there are no datetimeoriginal tag, so the condition failed. But at a result I get the filename "2017-11-21_12-44-43-test.m4v", the date with title instead of only the date while 1 condition failed.
Finaly I will check the quickTime:CreateDate, the datetimeoriginal is only for testing.
When I run the commandline exiftool -if "(($title) and ($datetimeoriginal))" "-FileName<$QuickTime:CreateDate-${title;tr/ /_/}.%le" FILE I get "1 files failed condition"
What goes wrong in the ARG-File?
Best regrads

Phil Harvey

It is one argument per line in the arg file, so it should look like this:

-FileName<$QuickTime:CreateDate.%le
-d
%Y-%m-%d_%H-%M-%S%%-c
-if
(($title) and ($datetimeoriginal))
-FileName<$QuickTime:CreateDate-${title;tr/ /_/}.%le


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

Quant007

Ah, thanks.
I tried this in different variations like:

-if
(($title) and ($datetimeoriginal))
-FileName<$QuickTime:CreateDate-${title;tr/ /_/}.%le

and

-if
"(($title) and ($datetimeoriginal))"
-FileName<$QuickTime:CreateDate-${title;tr/ /_/}.%le

and

-if
'(($title) and ($datetimeoriginal))'
-FileName<$QuickTime:CreateDate-${title;tr/ /_/}.%le

I get allways Error: File not found - '(($title) and ($datetimeoriginal))'
Any ideas?
Quant007

StarGeek

From the docs on the -if option
   Normal shell processing of arguments is not performed, which among other things means that arguments should not be quoted and spaces are treated as any other character.

I'm guessing there's a trailing space after -if.  That means exiftool is looks for a tag called if(space), not the option if.  As such, the if condition is no longer treated as the condition for the if and the only thing left is for it to be a filename.
* 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).

Alan Clifford

Quote from: StarGeek on July 08, 2020, 11:30:37 AM

I'm guessing there's a trailing space after -if

If you select the text as if you are going to copy/paste, you can see the space.

Quant007

Thanks to all, the trailing space after -if was the problem
Now it works perfekt.