Question to -b option in an argument file

Started by herb, July 10, 2019, 05:22:57 AM

Previous topic - Next topic

herb

Hello Phil,

I am working with Exiftool 11.54 on a Windows 7 system.
In order to export the previewimage of my *.jpg images (taken with an Olympus camera) I use the following command in DOS-box:
exiftool.exe -if $previewimage -b -previewimage -W! F:\test\test_prv.jpg test.jpg
Exiftool responds : 1 output files created - so it works properly.

But when I send this command from my C++ application via stdin to Exiftool I have a strange behaviour.
Exactly the same happens using an argument file in DOS-box:
exiftool.exe -@ argumentfile.args with the following argument file
-if $previewimage
-b
-previewimage
-W!
F:\test\test_prv.jpg
test.jpg


I get the following response:
(stderr)
Invalid TAG name: "if $previewimage"
Warning: Invalid tag name 'if $previewimage' - test.jpg
(stdout)
    1 output files created

The command is properly performed. The same happens e.g. with -thumbnailimage also.
On one hand this is not serious for my application because it does check stdout first; but on the other hand it would be helpful to know where the wrong messages on stderr do come from.

Best regards
Herb

Phil Harvey

Hi Herb,

You need one argument per line.  So try this:

-if
$previewimage
-b
-previewimage
-W!
F:\test\test_prv.jpg
test.jpg


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

herb

Hello Phil,

thanks for your quick help. It works perfect.

Best regards
Herb

george013

Seems that the argument file doesn't allow spaces. Is that also with path/file names?

George

Phil Harvey

The argument file does allow spaces within a single argument.  Separate arguments must be on separate lines.

- 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

Quote from: george013 on July 21, 2019, 08:08:41 AM
Seems that the argument file doesn't allow spaces. Is that also with path/file names?

Make sure you read the -@ (Argfile) option docs carefully.

Each command line arguments is on a separate line.  An example is in Herb's post above with the -W option.  The full -W listed above is -W! F:\test\test_prv.jpg but -W! and F:\test\test_prv.jpg are two separate arguments so they have to be on separate lines. 

Unlike the command line, arguments should not be quoted.  Things like redirection doesn't happen in an arg file.  You don't need to escape or quote spaces in a filepath.  For example, if the file path in the above mentioned example was F:\test\test prv.jpg, then that would be what is in the arg file, not "F:\test\test prv.jpg" or F:\test\test\ prv.jpg

Trailing spaces DO matter in an arg file.  For example, if you have a simple arg file that just lists the filename of a file but has a trailing space:
-Filename <-Note trailing space
You'll get this response
C:\>exiftool -g1 -a -s -@ temp3.txt y:\!temp\Test4.jpg
Invalid TAG name: "Filename "
"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

george013

Thanks for the replies.
I don't know anything of Perl and how the command lines are working. I've to study on the logics of that language, but no time at the moment. At first glance I would say that the statement "-if condition" would give a value false or true. But it seems to work different.

My point is to create a program that can add keywords to a rawfile. Easy  with exiftool, and I managed to call the command line exiftool from a Pascal program. Now creating the interface. :-[

George

StarGeek

Quote from: george013 on July 23, 2019, 03:36:01 PM
At first glance I would say that the statement "-if condition" would give a value false or true. But it seems to work different.

That is how it works.  If the condition is true, then the command is executed.  If it is false, the command is not executed. The thing to remember is that it is not an IF ... THEN statement.  The position doesn't matter.  The -if <condition> can be at the beginning, middle, or the end of the command and the whole command will either be processed or not.  So
exiftool -if "$Description eq 'old'" -Description=new File.jpg
is exactly the same as
exiftool File.jpg -Description=new -if "$Description eq 'old'"

The -if option is the same as the -W example above. The -if option is two separate arguments.  And the condition, which must be quoted on the command line, must not be quoted in an arg file.

Command line example (Windows version, swap double/single quotes for Mac/Linux):
-if "$Description eq 'old'"

Arg File example
-if
$Description eq 'old'


"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