BAT批处理文件

pgp 在做解密和加密的时候,命令行的方式总是需要手动输入密码和指定ID,比较繁琐,所以写了一个自动脚本。
比较有意思的地方是:
setlocal enabledelayedexpansion 变量延迟和!变量!的使用。同样的方式可以读入文本文件中不同行的内容来赋值变量

@echo off

:: todo
setlocal enabledelayedexpansion
set /a j=0
for /f "tokens=1-3 delims=" %%i in (ps.txt) do (
set /a j+=1
rem set /a j+=1
rem echo !j!
rem echo %%i
if !j!==1 set ps=%%i
rem if !j!==2 set txt=%%i

)
rem echo %ps%
rem echo %txt%
set inputfile=%1%
echo Decrypt the pgp file from WideVine portal - %inputfile%
set outputfile=%inputfile:~0,-28%xml
rem echo Output file - %outputfile%

gpg --passphrase %ps% --decrypt %inputfile% > %outputfile%
echo Decrypt the pgp file successfully.
echo Encrypt the %outputfile% with customer key

gpg -r widevine_keys -e %outputfile%
rm %outputfile%

猜你喜欢

转载自blog.51cto.com/wb127/2173864