Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JonTheNiceGuy/e2d6264ef81a13d536281be96ed826a6 to your computer and use it in GitHub Desktop.
Save JonTheNiceGuy/e2d6264ef81a13d536281be96ed826a6 to your computer and use it in GitHub Desktop.
This batch file is used to encrypt a file with GPG against a large number of recipient email addresses

Using this script

Place this batch file and the text file into the same directory, edit the batch file to specify the key server and the text file to specify the names to encrypt.

If you hit an issue where an individual has multiple keys against their name, the script may well complain and ditch responses. In this case, uncomment the line in the batch file which says: REM %COMMAND% --recv-keys <KEY ID>

So it should say instead: %COMMAND% --recv-keys DECAFBAD

recipient name@example.com
recipient name2@example.com
@echo off
REM SCRIPTNAME: run_gpg.bat
REM AUTHOR: Jon Spriggs
REM VERSION: 1.0
REM RELEASE: 2016-04-04
REM LICENSE: GNU General Public License 3.0
REM ABOUT: This script is used to automate the GPG encryption of any file to a series of email addresses.
REM NOTES: You must run this from the path where the batch file and text files are located.
set COMMAND=gpg --no-options
set COMMAND=%COMMAND% --trust-model always
set COMMAND=%COMMAND% --mangle-dos-filenames
set COMMAND=%COMMAND% --no-default-keyring
set COMMAND=%COMMAND% --keyserver ldap://your.key.server.here
set COMMAND=%COMMAND% --auto-key-locate keyserver
set COMMAND=%COMMAND% --quiet
set COMMAND=%COMMAND% --primary-keyring ".\pubring.pkr"
set COMMAND=%COMMAND% --secret-keyring ".\secring.skr"
REM If you need to add particular keys (for example, where several matching strings occur) then uncomment this line:
REM %COMMAND% --recv-keys <KEY ID>
set COMMAND=%COMMAND% --options ".\email address list.txt"
%COMMAND% --encrypt %1
del pubring.* secring.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment