BAT批处理文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 -----------------------------------------------------------
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批处理文件的主要内容,如果未能解决你的问题,请参考以下文章

bat批处理文件 删除制定文件夹当前日期3个月以前的文件

bat文件命令大全

Windows 批处理文件 (.bat) 复制命令怎么写?

bat文件

批处理(bat)批量打开文件夹下的所有PDF文档

cmd下执行bat文件的命令