1
我有以下文件树批处理脚本来创建一个ZIP文件进行陈述的文件和文件夹列表的
|
|--/BlueFolder1/
|----Blue.txt
|----Blue2.exe
|--/BlueFolder2/
|----Blue.exe
|-Blue2.exe
|-Red.md
|-Blue.txt
|-MySuperAwesomeScript.bat
我需要一个批处理脚本ZIP所有的“蓝色”文件到一个BlueFiles.zip
存档。
我对这些技术确实无效,但我认为我应该列出要压缩的文件,或者如果可能的话,将哪些文件声明为IGNORE。
我发现这个批处理脚本的作用像一个魅力,但它不让我选择哪些文件不包含/包含。
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET sourceDirPath=%1
IF [%2] EQU [] (
SET destinationDirPath="%USERPROFILE%\Desktop"
) ELSE (
SET destinationDirPath="%2"
)
IF [%3] EQU [] (
SET destinationFileName="%~n1%.zip"
) ELSE (
SET destinationFileName="%3"
)
SET tempFilePath=%TEMP%\FilesToZip.txt
TYPE NUL > %tempFilePath%
FOR /F "DELIMS=*" %%i IN ('DIR /B /S /A-D "%sourceDirPath%"') DO (
SET filePath=%%i
SET dirPath=%%~dpi
SET dirPath=!dirPath:~0,-1!
SET dirPath=!dirPath:%sourceDirPath%\=!
SET dirPath=!dirPath:%sourceDirPath%=!
ECHO .SET DestinationDir=!dirPath! >> %tempFilePath%
ECHO "!filePath!" >> %tempFilePath%
)
MAKECAB /D MaxDiskSize=0 /D CompressionType=MSZIP /D Cabinet=ON /D Compress=ON /D UniqueFiles=OFF /D DiskDirectoryTemplate=%destinationDirPath% /D CabinetNameTemplate=%destinationFileName% /F %tempFilePath% > NUL 2>&1
DEL setup.inf > NUL 2>&1
DEL setup.rpt > NUL 2>&1
DEL %tempFilePath% > NUL 2>&1
在此先感谢。