码迷,mamicode.com
首页 > 其他好文 > 详细

BAT批处理文件

时间:2018-09-11 17:06:48      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:for   local   地方   文件   txt   XML   gpg   custom   dev   

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 -----------------------------------------------------------
echo Decrypt the pgp file from WideVine portal - %inputfile%
echo -----------------------------------------------------------
echo;
set outputfile=%inputfile:~0,-28%xml
rem echo Output file - %outputfile%

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

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

BAT批处理文件

标签:for   local   地方   文件   txt   XML   gpg   custom   dev   

原文地址:http://blog.51cto.com/wb127/2173864

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!