
批處理分別調(diào)用7Zip和WinRAR把文件批量分組壓縮成zip格式【方法1】7-Zip
【方法2】WinRARnclick="copycode($('code0'));">復(fù)制代碼
- @echo off
- setlocal enabledelayedexpansion
- REM 設(shè)置多少個(gè)文件壓縮成同一個(gè)包
- set GroupSize=3
- REM 假設(shè)7-Zip安裝在以下目錄
- set SevenZip=C:Program Files7-Zip7z.exe
- set ZipCounter=1
- set FileCounter=0
- REM 假設(shè)需要壓縮的是當(dāng)前目錄下的txt文件
- for /f delims= %%i in ('dir /b /a-d *.txt') do (
- %SevenZip% u !ZipCounter!.zip %%i
- set /a FileCounter+=1
- if !FileCounter! equ %GroupSize% (
- set /a ZipCounter+=1
- set FileCounter=0
- )
- )
nclick="copycode($('code1'));">復(fù)制代碼
- @echo off
- setlocal enabledelayedexpansion
- REM 設(shè)置多少個(gè)文件壓縮成同一個(gè)包
- set GroupSize=3
- REM 假設(shè)WinRAR安裝在以下目錄
- set WinRAR=C:Program FilesWinRARWinRAR.exe
- set ZipCounter=1
- set FileCounter=0
- REM 假設(shè)需要壓縮的是當(dāng)前目錄下的txt文件
- for /f delims= %%i in ('dir /b /a-d *.txt') do (
- %WinRAR% a -ibck !ZipCounter!.zip %%i
- set /a FileCounter+=1
- if !FileCounter! equ %GroupSize% (
- set /a ZipCounter+=1
- set FileCounter=0
- )
- )

