Working with an argument file

Started by herb, July 18, 2015, 06:16:50 AM

Previous topic - Next topic

herb

Hello Phil,

I am working with Exiftool V9.98 on a windows XP system.
I am developing a small tool as simple GUI for exiftool itself.
I start Exiftool with option:-stay_open -@ - and send the command via stdout->stdin

In case of also using an argumentfile within the command I get an unexpected behaviour:
- I have a *.jpg image as testfile that contains exif, iptc and xmp metadata.
- The testcase is to rebuild the exif-metadata, to delete the xmp-metadata and to keep the iptc-metadata unchanged.
  For me the important goal is to also use an argumentfile - in my testcase an argumentfile that deletes xmp metadata.
- The unexpected behaviour occurs only working via exiftool stdin.

When I send the following command via DOS-box
exiftool -charset filename=utf8 -use mwg -m -z
            -exif:all=
            -tagsfromfile @
            -exif:all
            -@ f:\a1.arg   ( a1 exists and contains 1 line: -xmp:all= )
            f:\test.jpg

the file test.jpg is updated as expected.
I know that the above command contains unnecessary options, but as the command is generated by my tool i give them all here.

When I send the command - but with a not existing argumentfile a2.arg - Exiftool sends an error message:
    error opening arg file: f:\a2.arg
and the image is unchanged.
This is all ok for me.

The unexpected behaviour occurs when I work with my tool that sends the command to Exiftool stdin.
Exiftool has been started with option: -stay_open -@ -

When I send the above given command ( each part is seperated by NEWLINE and followed by -execute111 )
the command is executed properly and Exiftool responds with {ready111}.
(So I think there is no syntax error.)

But when I send the command with a not existing argumentfile, Exiftool respondes:
{ready}
all metadata of file ( about 90 lines)
error message for not existing argument file: error opening arg file: f:\a2.arg

The image file is unchanged as in case of working with DOS-box.

What am I doing wrong?
Why does Exiftool display all existing metadata of the image?
Please advice.

Thank you very much in advance.
Best regards
Herb

Phil Harvey

#1
Hi Herb,

Ah.  I see.  I'll have to think about this.

There are certain command-line errors that will cause the command to be aborted.  A missing argfile is one of them.  So the command is aborted after the missing argfile and the {ready} response is sent, then the rest of the arguments you intended for that command are interpreted as a new command. 

Clearly, this isn't desirable.  I'll have to think about how to fix this.

For now, at your end, place the -@ as the last argument to avoid executing another command with the remaining arguments.

- Phil

Edit:  I think I have solved the problem.  ExifTool should be ignoring all arguments until the -execute after it decides to abort a command.  I will implement this in the next release.  Thanks for this report.
...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 reply and thanks for thinking about a correction in Exiftool.

But please allow to discuss an additional problem:
In case of sending the command via stdin and in case of the argumentfile does not exist and
(--new--) in case of my testfile (till now f:\test.jpg) has a name that contains also unicode characters
Exiftool does send 2 error messages:
   error opening arg file: f:\a2.arg and
   File not found: f:\testX.jpg (that now contains an unicode character X).

Thanks again for your help
Best regards
Herb

Phil Harvey

Hi Herb,

The Unicode character thing is a different problem.  See FAQ 10 and the WINDOWS UNICODE FILE NAMES section of the application documentation for help with this.

- 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 comments. But I think we have a little misunderstanding. What I wanted to explain is the following:
Sending the command via stdin
exiftool -charset filename=utf8 -use mwg -m -z
            -exif:all=
            -tagsfromfile @
            -exif:all
            -@ f:\a1.arg   ( a1 exists and contains 1 line: -xmp:all= )
            f:\testX.jpg    ( with X being a Unicode character and file exists)

works fine.
But in case of the argument file does not exist, Exiftool gives an additional error report: File not found f:\textX.jpg
Is this the correct behaviour?
Or is it also solved when --  ExifTool ignors all arguments until the next -execute.  ( as proposed correction)?

Of course I did not test this via DOS-box, because I cannot enter Unicode characters here.

Best regards
Herb

Phil Harvey

Hi Herb,

Yes.  This is solved when ExifTool ignores the arguments for an aborted command.

- 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 the new version of Exiftool and thanks for the correction.
It works wonderful.

Best regards
Herb

Phil Harvey

Hi Herb,

Great.  Thanks for the verification, and for bringing this to my attention in the first place.

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