您如何排除在主文件中压缩子文件?
How would you exclude compressing a sub file inside a main file?
@ECHO OFF
SET hr=%time:~0,2%
IF %hr% lss 10 SET hr=0%hr:~1,1%
Set TODAY=%date:~4,2%-%date:~7,2%-%date:~10,4%-%hr%%time:~3,2%%time:~6,2%%time:~9,2%
ECHO.
ECHO.
这将是要从压缩
中排除"C:\Users\Downloads\back\temp" 的文件夹
7za.exe a -tzip "C:\Users\Desktop\Downloadbak-%TODAY%.zip" "C:\Users\Downloads\back*" -mx5
ECHO.
PAUSE
将当前文件夹更改为基本文件夹并使用 -x
开关:
pushd C:\Users\Downloads\back
7za.exe a -tzip -mx5 -x!temp -x!exclude2 "C:\Users\Desktop\Downloadbak-%TODAY%.zip" *
popd
或通过管道将 dir
输出到 find
以排除文件夹名称并将结果用作 7zip 的列表文件:
pushd C:\Users\Downloads\back
dir /b /a | findstr /i /v /r /c:"^temp$" >"%temp%\listfile"
7za.exe a -tzip -mx5 "C:\Users\Desktop\Downloadbak-%TODAY%.zip" @"%temp%\listfile"
del "%temp%\listfile"
popd
@ECHO OFF
SET hr=%time:~0,2%
IF %hr% lss 10 SET hr=0%hr:~1,1%
Set TODAY=%date:~4,2%-%date:~7,2%-%date:~10,4%-%hr%%time:~3,2%%time:~6,2%%time:~9,2%
ECHO.
ECHO.
这将是要从压缩
中排除"C:\Users\Downloads\back\temp" 的文件夹 7za.exe a -tzip "C:\Users\Desktop\Downloadbak-%TODAY%.zip" "C:\Users\Downloads\back*" -mx5
ECHO.
PAUSE
将当前文件夹更改为基本文件夹并使用
-x
开关:pushd C:\Users\Downloads\back 7za.exe a -tzip -mx5 -x!temp -x!exclude2 "C:\Users\Desktop\Downloadbak-%TODAY%.zip" * popd
或通过管道将
dir
输出到find
以排除文件夹名称并将结果用作 7zip 的列表文件:pushd C:\Users\Downloads\back dir /b /a | findstr /i /v /r /c:"^temp$" >"%temp%\listfile" 7za.exe a -tzip -mx5 "C:\Users\Desktop\Downloadbak-%TODAY%.zip" @"%temp%\listfile" del "%temp%\listfile" popd