Batch script GPG encryption automation

October 8, 2010 at 03:39:29
Specs: Windows 7
SETLOCAL
PATH=C:\Program Files (x86)\GNU\GnuPG;%PATH%
>"%TMP%\~encryptlist.txt" DIR /B "C:\outgoingdropfolder"
PUSHD "C:\outgoingdropfolder"
FOR /F "delims=" %%F IN ('MORE ^< "%TMP%\~encryptlist.txt"') DO (
IF EXIST %%F (
ECHO bingos| GPG --batch -se --passphrase-fd 0 -r PGPTOKEY -o "C:\encryptedfiles\%F.pgp"
IF ERRORLEVEL == 0 DEL "%%F"
)
)
POPD
DEL "%TMP%\~encryptlist.txt"
ENDLOCAL

above is the script im using to try and automate GPG the above is working sort off

let me explain what i want it to do

a User can drop any type of file, called anything they like into the dropfolder, when the batch runs, i want the file (or files) to be encrypted (all with the same encryption and signing key) and then outputted to the folder called encrypted files, the file names must be the same as they were when they went in, except obviousley the new pgp extension. (i require the output to be a PGP extension)

This is what happens when i run the above batch.

I drop a file called lee.txt (10mb) into dropfolder, run the batch, the file dissapears from drop folder, and appears in the encypted files folder with the file name f.PGP ? and is only 1kb in size ?

the encryptlist.txt appears to be working fine. Im hoping that it will be able to handle more than one file ( I asume that is what the encrypt list is for ?
) however im unable to confirm as the files are becoming over written when they get to encrypted folder. If i drop 2 files at the same time then the encrypted list does pick up 2 different file names.

I can confirm that encyption and signing is working as it should, i can suucesfully decypt and verify signature using PGP, (but like i said, the file is empty)

Hope ive explained clearly enough
Lee


See More: Batch script GPG encryption automation

Report •


#1
November 21, 2010 at 11:17:11
Hi
i was having similar problem and was looking for a batch file to excrypt text files automatically , could you please help.

Report •

#2
November 21, 2010 at 13:35:45
This works for me fine.........

SETLOCAL
PATH=C:\Program Files (x86)\GNU\GnuPG;%PATH%
>"%TMP%\~encryptlist.txt" DIR /B "C:\outgoingdropfolder"
PUSHD "C:\outgoingdropfolder"
FOR /F "delims=" %%F IN ('MORE ^< "%TMP%\~encryptlist.txt"') DO (
IF EXIST %%F (
ECHO password| GPG --batch -se --passphrase-fd 0 -r PGPTOKEY -o "C:\encryptedfiles\%%F.pgp" %%F
IF ERRORLEVEL == 0 DEL "%%F"
)
)
POPD
DEL "%TMP%\~encryptlist.txt"
ENDLOCAL


Report •
Related Solutions


Ask Question