Processing a list of files

Started by Skids, February 07, 2025, 07:45:12 AM

Previous topic - Next topic

Skids

Hi,

My aim is to write one or more keywords to a number of images that are stored in a list of file paths.  My code will build the shell script on the fly so I could issue the shell command once per file in the list but I believe that this is a slow way to perform the editing of tags as exiftool will have to be started and then restarted on each pass.

However back in 2019 Phil wrote
QuoteThe -@ argfile does work for file lists.  Don't quote the file names.

- Phil

Does this imply that each file path is an argument ?

I am unclear how to present the list to exiftool.  For example does the @ argfile accept a string variable and should all the arguments be included in the variable or can these precede the @ argfile in the string that is the shell script?

Quotee.g. Set MyShellCommand to "/usr/local/bin/exiftool -m -keywords+= " & Newkeyword & " @ argfile " & MyListOfFiles

Where '&' is the text concatenation symbol meaning that MyShellCommand is a string variable ready to be passed to a 'do shell script' command in Applescript.

I have not tried any code yet as having read and not understood the documentation I thought it better to ask.

best wishes
Simon


Phil Harvey

Hi Simon,

The -@ option accepts a path name.  (eg. -@ /path/to/my.args)  It reads additional command-line arguments (eg. image file names) from the file, one argument per line.

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

StarGeek

The tl;dr, the argument after -@ must be an actual file on the disk, or it can be a minus sign to indicate data is piped from STDIN

Quote from: Skids on February 07, 2025, 07:45:12 AMso I could issue the shell command once per file in the list, but I believe that this is a slow way to perform the editing of tags as exiftool will have to be started and then restarted on each pass.

Yes, this is slower. This is Common Mistake #3

QuoteHowever back in 2019 Phil wrote
QuoteThe -@ argfile does work for file lists.  Don't quote the file names.

Does this imply that each file path is an argument ?

Yes

QuoteI am unclear how to present the list to exiftool.  For example does the @ argfile accept a string variable and should all the arguments be included in the variable or can these precede the @ argfile in the string that is the shell script?

Exiftool can't process a list directly from a variable because it won't have direct access to the script variables. Exiftool isn't a function of whatever scripting language you are using. It will have to be called as an external program which means it would have to be formatted as it would be on the command line.

Passing a file list from a variable in that way would require that the data be part of a single line and quoted, as it the same as running it from the command line. The -@ option would not be involved

As the docs on the FAQ #29, "My options don't work in a -@ ARGFILE" say (emphasis mine)
QuoteRead command-line arguments from the specified file

So the argument to -@ must be a file. Note that this can either be a file on the disk, e.g. a temp file, or it can be from STDIN (use the minus sign for STDIN) such as the output from a pipe.

For example, I have VoidTools Everything Search installed. If I wanted the metadata from all mp3 files on my system, I could use the Everything Search command line to generate this list and then pass the data directly to exiftool
es ext:mp3 | exiftool -G1 -a -s -@ -

For Mac/Linux, you can see an example of using find the same way in this post.

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Skids