News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

-p option fails inside argument file

Started by spmazurek, April 15, 2020, 12:27:14 PM

Previous topic - Next topic

spmazurek

I love this tool! I haven't coded in a very long time and wasn't looking forward to extracting EXIF data from image files with my own code.

I've read through the document(s) and have a fairly good grasp of the basic functions. The one thing I am having a problem with is the print format (-p) option in an arguments file. My basic args.txt file works until I add a print format option. I've tried the short version and the verbose version. I used quotes and no quotes, I tried escaping characters. It always fails with: Warning: Invalid tag name '> $filename' - test.jpg .

The contents of the args.txt file is:
-k
-q
-p >> $filename
-filename
#-XMP:Title
#-XMP:ImageSupplierImageID

and the command line I use is:

exiftool.exe -@ args.txt test.jpg

If I move the print format option to the command line and quote the string it works every time.

The details:

Windows 10 Home
exiftool version 11.93
everything reside in the same directory


Any thoughts on why this might be failing?

StarGeek

Quote from: spmazurek on April 15, 2020, 12:27:14 PM
-p >> $filename

I'm trying to figure out what you're trying to do here.  Are you trying to redirect the output into a file?  If so, that's a function of the CMD and can't be placed inside an args file.

Additionally, the -p (printFormat) option requires a second argument, either a text file that gives the format to be printed, or a string that holds the format to be printed.  Also, since it's a separate argument, it needs to be on a separate line.

If the format your trying to print out is
FileName XMP:Title XMP:ImageSupplierImageID
Then your arg file for this part should be
-p
$FileName $XMP:Title $XMP:ImageSupplierImageID

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

spmazurek

I'm not doing anything fancy just testing capability. The # lines are commented out because I am just attempting to get the -p to work. All I am looking for is an output that reads: >> test.jpg.  The -filename is redundant: to lazy to delete it.

On the -p line, the >> is a text output and $filename is a variable - quite simple. There is no redirecting going on here. According to my reading of the documentation, everything after -p that is  not a variable is treated as text for output.  Besides, I tried using quotes and that didn't work either.  :(

But you did raise the specter that it might be trying in interpret the ">>" as a redirect so I changed to the arg.txt file to read:


-k
-q
-p My file name is $filename
#-XMP:Title
#-XMP:ImageSupplierImageID


The results were still : Invalid TAG name: "p My file name is $filename".

It's as though a portion of that line in the args.txt file is be absorbed and not introduced as a command line argument properly.

Thoughts?  Can you replicate this?




StarGeek

Quote from: StarGeek on April 15, 2020, 01:19:35 PM
Also, since it's a separate argument, it needs to be on a separate line.

-p on one line. My file name is $filename on the second line.  Make sure and remove the trailing space from the -p
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

spmazurek

Yup, that was it. I guess I was too smart by 1/2. I misinterpreted the  quoted line when I read it. I'm so used to putting an option's argument next to the option flag. 

Thanks for the help!  :D

Phil Harvey

This comes up often enough that I have added it as FAQ 29.

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