以下代码运行时没有错误,但实际上并没有压缩文件。我无法在代码行中弄清楚我的错误"%ZipProgram%"。
@echo off
:: Get the current directory.
set CurrDir=%cd%
:: Find the 7-Zip program.
set ZipProgram="C:\Program Files\7-Zip\7z.exe"
if not exist %ZipProgram% (
set ZipProgram="C:\Program Files (86)\7-Zip\7z.exe"
)
if not exist %ZipProgram% (
set ZipProgram="C:\Program Files\Easy 7-Zip\7z.exe"
)
if not exist %ZipProgram% (
set ZipProgram="C:\Program Files (86)\Easy 7-Zip\7z.exe"
)
:: %%n is the variable n specified in a batch file. From a command line it would be %n.
:: /D specifies loop through Directory names only.
FOR /D %%n in ("%CurrDir%\*.*") DO (
%ZipProgram% u -y -t7z "%%n.7z" "%%n" -r -x!*.tmp
)
pause