How to Pass arguments on the command line with -stay_open True

Started by mxdog, February 03, 2024, 07:27:15 AM

Previous topic - Next topic

mxdog

I have been trying to get ExifTool to work with a c# program I am writing to retrieve title and year from a mp4 collection and am having trouble passing arguments on the command line ( no file ), A couple of problems I am having is one ExifTool seems to want to strip double quotes and what i have tried from the help file does not seem to work as far as options are concerned i.e -T -title -contentcreateddate ...etc..


following is my process code ( for testing I am not redirecting input/output so the command window stays open and I can cut and paste attempts )

#########################

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.StartInfo.FileName = "cmd.exe";
string args = "/K  exiftool  -title -T  -stay_open True -@ - "; // and many variations on this
process.StartInfo.Arguments = args;
process.StartInfo.UseShellExecute = true;
process.StartInfo.CreateNoWindow = false;
process.StartInfo.RedirectStandardOutput = false;
process.StartInfo.RedirectStandardInput = false;
process.Start();

That will open a window and be ready to accept input
   
INPUT
"F:/Media/Videos/Not-Watched/AROUND_THE_WORLD_IN_80_DAYS_Part-1_1955.mp4"
-execute
will produce and error File not found

F:/Media/Videos/Not-Watched/AROUND_THE_WORLD_IN_80_DAYS_Part-1_1955.mp4
-execute
will return all the tags/meta in the file with standard Tag : Data format but NO format options working

-T -title F:/Media/Videos/Not-Watched/AROUND_THE_WORLD_IN_80_DAYS_Part-1_1955.mp4
-execute
 gives Invalid TAG name: "T -title ( see how it strips the - ? )

So the question is how to format my arguments list variables to actually work bearing in mind that I will have a few files with spaces so Quotes ARE needed?

Phil Harvey

This isn't the command line, you are passing arguments via a pipe, so no shell processing is done.  So most of your problems are explained by FAQ 29

And the options on the command line apply only to the first -execute'd command.

You need to do this:

-T
-title
F:/Media/Videos/Not-Watched/AROUND_THE_WORLD_IN_80_DAYS_Part-1_1955.mp4
-execute

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