目录中有多个文件夹,我想分别压缩原始文件夹FolderName.zip
,压缩后删除原始文件夹。该目录中还有其他已压缩的文件夹,我想保留原样。我用来压缩文件的工具是 7z,因为它以前用于手动压缩。以下是我尝试作为批处理文件运行的代码,但它失败了,只是出现空白屏幕
@ECHO OFF
SET SrcDir=G:\Backup\IPE\DAT
SET DestDir=G:\Backup\IPE\DAT\folderName.zip
IF NOT EXIST "%DestDir%" MD "%DestDir%"
ECHO.
ECHO Compressing files and folders in G:\Backup\IPE\DAT\ drive
ECHO.
ECHO Compressing files and folders in G:\Backup\IPE\DAT\ drive and then delete original folders
ECHO.
FOR %%A IN ("%SrcDir%\*.*") DO 7za a -tzip "%DestDir%\%%~NA.zip" "%%~A" -mx5 && DEL /Q /F "%%~A"
ECHO.
PAUSE