Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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