
我會gzip一個目錄下所有目錄中的所有html文件,同時刪除未壓縮的文件。
for /r %%i in (*.html) do "c:\7-zip\7z.exe" a -aoa -mx=9 -tgzip -sdel "%%~ni.gz" "%%i"
此命令列部分有效,但不會對其目錄中的每個 html 檔案進行 gzip 壓縮,而是對父目錄中的所有檔案進行 gzip 壓縮。
如果我這樣做
for /r %%i in (*.html) do "c:\7-zip\7z.exe" a -aoa -mx=9 -tgzip -sdel "%%i.gz" "%%i"
它對目錄中的每個檔案進行 gzip 壓縮,但保留 .html
我已經找到解決方案了
for /r %%i in (*.html) do "c:\7-zip\7z.exe" a -aoa -mx=9 -tgzip -sdel "%%~pni.gz" "%%i"