Page MenuHome GnuPG

(An Untitled Masterwork)
ActivePublic

Authored by aheinecke on Jun 4 2021, 1:12 PM.
@echo off
REM Set the GnuPG homedir here accordingly
set GPGHOME=c:\users\Andre Heinecke\AppData\Roaming\gnupg
REM Set the input / output directory
set INDIR=c:\input-files
set OUTDIR=c:\output-files
set INPUTEXT=.gpg
set OUTPUTEXT=
cd %INDIR%
mkdir %OUTDIR% 2>nul
for /R %%f in (*%INPUTEXT%) do (
setlocal enabledelayedexpansion
for %%i in ("%%f") do (
set filename=%%~ni
)
set OUTPATH=%OUTDIR%\!filename!%OUTPUTEXT%
echo Decrypting %%f into !OUTPATH! >> "%OUTDIR%\decrypt.log"
rem Overwrite handling?
gpg --verbose --homedir "%GPGHOME%" --yes --batch --log-file "%OUTDIR%\decrypt.log" -o "!OUTPATH!" -d -- "%%f"
if !ERRORLEVEL! NEQ 0 (
echo Operation failed with return code: %ERRORLEVEL% >> "%OUTDIR%\decrypt.log"
) else (
echo Operation finished successfully >> "%OUTDIR%\decrypt.log"
cd "%OUTDIR%"
tar -xf "!OUTPATH!"
if !ERRORLEVEL! NEQ 0 (
echo Extracting failed with return code: %ERRORLEVEL% >> "%OUTDIR%\decrypt.log"
) else (
echo Deleting %%f >> "%OUTDIR%\decrypt.log"
del "%%f" >> "%OUTDIR%\decrypt.log" 2>&1
rem echo Deleting !OUTPATH! >> "%OUTDIR%\decrypt.log"
del "!OUTPATH!" >> "%OUTDIR%\decrypt.log" 2>&1
)
)
)