ExifTool Forum

ExifTool => Newbies => Topic started by: Quant007 on July 08, 2020, 05:20:33 AM

Title: -IF in a ARG-File
Post by: Quant007 on July 08, 2020, 05:20:33 AM
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
Title: Re: -IF in a ARG-File
Post by: Phil Harvey on July 08, 2020, 06:06:04 AM
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
Title: Re: -IF in a ARG-File
Post by: Quant007 on July 08, 2020, 07:46:31 AM
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
Title: Re: -IF in a ARG-File
Post by: StarGeek on July 08, 2020, 11:30:37 AM
From the docs on the -if option (https://exiftool.org/exiftool_pod.html#if-NUM-EXPR)
   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.
Title: Re: -IF in a ARG-File
Post by: Alan Clifford on July 08, 2020, 11:54:19 AM
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.
Title: Re: -IF in a ARG-File
Post by: Quant007 on July 11, 2020, 07:47:10 AM
Thanks to all, the trailing space after -if was the problem
Now it works perfekt.