ExifTool Forum

ExifTool => Newbies => Topic started by: dwlott on March 16, 2022, 06:47:06 PM

Title: convert long command string to arg file
Post by: dwlott on March 16, 2022, 06:47:06 PM
Hello, I am bumping up against the 8191 command line character limit in windows.  So my need is to understand what an arg file would look like.  In practice, I am working with perhaps a hundred or more files with many meta fields.  The -execute option works great up until I reach the character limit in windows. 

My example command:

e:\exiftool\exiftool -IPTC:City="Miami" -IPTC:Province-State="Florida" -IPTC:Country-PrimaryLocationName="USA" "e:\exiftool\mySourceFolder\Earrings\ERP1011-5.jpg" -execute -IPTC:City="Miami" -IPTC:Province-State="Florida" -IPTC:Country-PrimaryLocationName="USA" "e:\exiftool\mySourceFolder\Earrings\ERP1013-3.5.jpg" -execute  > e:\exiftool\out.tsv

Thank you for any help and advice. 
Title: Re: convert long command string to arg file
Post by: StarGeek on March 16, 2022, 07:22:00 PM
See FAQ #29 (https://exiftool.org/faq.html#Q29) and the -@ (Argfile) option (https://exiftool.org/exiftool_pod.html#ARGFILE).

Bascially, each item needs to be on a separate line, no quotes are used, and no trailing spaces unless they are part of the command.  Options that have two parts, for example, -sep ", ", would be split as per the above FAQ.

Your example would be split as
-IPTC:City=Miami
-IPTC:Province-State=Florida
-IPTC:Country-PrimaryLocationName=USA
e:\exiftool\mySourceFolder\Earrings\ERP1011-5.jpg
-execute
-IPTC:City=Miami
-IPTC:Province-State=Florida
-IPTC:Country-PrimaryLocationName=USA
e:\exiftool\mySourceFolder\Earrings\ERP1013-3.5.jpg


The redirection >e:\exiftool\out.csv is not an exiftool command but a property of the command line, so it can't appear in the args file.  Also, you don't need an execute at the end.  The final command is executed when the end of the command is reached.  Otherwise the final command ends up the equivalent of just running exiftool without any options, which usually means extracting and displaying all file data.

In the case of your example command, though, you don't need to execute on every file separately.  Since your example sets the same tags to the same value, you could use
-IPTC:City=Miami
-IPTC:Province-State=Florida
-IPTC:Country-PrimaryLocationName=USA
e:\exiftool\mySourceFolder\Earrings\ERP1013-3.5.jpg
e:\exiftool\mySourceFolder\Earrings\ERP1011-5.jpg


You'll also want to look at the -Common_Args option (https://exiftool.org/exiftool_pod.html#common_args).  You would set options after -Common_Args that would apply to each part of the command.  For example, the -P (-preserve) option (https://exiftool.org/exiftool_pod.html#P--preserve) and -overwrite_original option (https://exiftool.org/exiftool_pod.html#overwrite_original) are common commands to place after -Common_Args.

If you get unknown tag errors, then you'll want to check for options that need to be on separate lines and for trailing spaces.  For example, if you wanted to list Description in an arg file, but you typed
-Description(TrailingSpace)
exiftool would be looking for a tag called Description that includes a trailing space, which would never exist.
Title: Re: convert long command string to arg file
Post by: dwlott on March 16, 2022, 11:25:14 PM
Thank you StarGeek, your answer gives me a good way to move forward.