Usage of -stay_open option

Started by MOL, February 23, 2011, 02:18:34 PM

Previous topic - Next topic

MOL

Phil

Would you mind to shed a little bit more light on the usage of the -stay_open option, especially in conjunction with the command line?

From what I understand, it works like this:

a) Create an empty arg file
b) Add arguments to the file, one argument per line
c) Open command line
d) Call exiftool -stay_open true -@ arg.txt and process an image file
e) Overwrite arguments in arg file with new ones to process a different image file

And then? Do I have to call exiftool from the command line again or does it read the new arguments automatically since it hasn't been closed yet? I am not talking about batch processing, I want to keep ExifTool running and retrieving meta tags from an image whenever there is a request by a user to do so.

Thanks
Uwe

Phil Harvey

#1
Hi Uwe,

Your steps are correct up to this point, but this is wrong:

Quote from: MOL on February 23, 2011, 02:18:34 PM
e) Overwrite arguments in arg file with new ones to process a different image file

You do not overwrite existing arguments.  Just append new arguments to the file and exiftool will read them.  After you have written all of the arguments for a command (including the target file names), write -execute to the file and exiftool will execute this command.  Exiftool will stay running after the command is excuted, then you just append more arguments to the file for the next command and repeat the process as many times as you want.  It continues reading the argument file at the point were it left off after the previous -execute option.
[/quote]

- Phil

Edit: I just noticed that I have a propensity for miss-typing your name. Sorry.  I've fixed it here too.
...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 ($).

MOL

Thanks a lot, Phil. Just one more question: because I cannot simply overwrite the old arguments as you've said, the file can (theoretically) grow quite large over time. Is there a way to prevent this from happening other than closing ExifTool and restarting it with a newly created arg file?

Uwe

Phil Harvey

Hi Uwe,

Quote from: MOL on February 23, 2011, 03:06:21 PM
Is there a way to prevent this from happening other than closing ExifTool and restarting it with a newly created arg file?

Sure.  There are 2 ways:

1) Pipe your arguments to stdin of exiftool using -@ - to avoid the argument file altogether.

or

2) Change argument files periodically using the steps outlined in the -stay_open documentation, then erase the old argfile after you have changed to the new one.

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

MOL

#4
Thanks again, Phil, and sorry for the last question. I overlooked that part of the documentation and also one thread where the same question was already answered.

Uwe

Phil Harvey

I should mention that the first technique (-@ -) may be slightly faster than if you are using a file.  Depending on the system, there may be a delay (average of 5 milliseconds) when excuting a command via a -stay_open argument file, but this delay may not exist when using the pipe.

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