Sign Multiple Files using GPG CLI

So I can successfully automate the signing of one file… but I may have the need to sign any file in a certain directory during my automation process… here’s what my script looks like:

gpg --batch --passphrase “PASSPHRASE” --local-user “USER” --sign “C:\FOLDERS*.txt”

So in theory, all txt files should be signed… this script works fine if there’s one txt file in the folder. When I have two or more files in the folder I get a response that says:

“usage: gpg [options] --sign [filename]”

I’m assuming this means it finds more than one file, and wants a specific file name. is there a parameter to search more than one file name? or am I going to have to do some sort of for loop?

I think this is a known problem. wild cards used to work many versions ago and I don’t know if it has been fixed yet in the new versions. I usually call the command line from within a program like Toad or SSIS so I use a loop that sets a variable with the current file name being processed and then call the command line passing that variable value to the batch as an argument.

Wildcard support is fixed (Otherwise --sign *.txt would not work with a single file) but signing multiple files is just not supported by gnupg.

https://bugs.g10code.com/gnupg/issue1041

So calling it in a loop from a batch script or another program is the right way to go.