cmd實現cab文件的壓縮與解壓


壓縮(makecab):

1.單文件壓縮

makecab ip2.txt ip2.txt.cab

 

2.多文件壓縮

makecab /f c:\list.txt /d expresstype=mszip /d expressmemory=21 /d maxdisksize=1024000000 /d diskdirectorytemplate=C:\cab\ /d cabinetnametemplate=test.cab

其中:

/f 指定的c;\list.txt(路徑自定義)是你要進行壓縮的文件的列表,不能包含文件夾,在根文件下的子文件夾中不能包含相同文件名的文件,因為cab壓縮后不保留文件結構,就是類似於將多個文件壓縮到一個文件夾下,否則會報錯(ERROR: Duplicate file name)。

  list.txt 可以使用: 

for /r %i in (你的目錄\*.*) do echo %i >>c:\list.txt

 

/d 指定變量

expresstype=mszip  //壓縮類型:MSZIP,LZX
expressmemory=21 //壓縮占用內存
maxdisksize=1024000000  //生成的cab文件最大占用的磁盤容量
diskdirectorytemplate=C:\cab\  //生成的cab文件的路徑
cabinetnametemplate=test.cab  //cab文件名
UniqueFiles="OFF" //沒用過
Cabinet=on   //沒用過

結果:

Cabinet Maker - Lossless Data Compression Tool

2,103,331 bytes in 27 files
Total files:             27
Bytes before:     2,103,331
Bytes after:      1,017,699
After/Before:            48.39% compression
Time:                     1.56 seconds ( 0 hr  0 min  1.56 sec)
Throughput:            1315.00 Kb/second
expand -d c:\cab\test.cab
Microsoft (R) 文件擴展實用程序
版權所有 (c) Microsoft Corporation。保留所有權利。

 

解壓(expand):

1.查看cab文件中壓縮文件列表

expand -d c:\cab\test.cab

2.提取cab文件中的單個文件

expand c:\cab\test.cab -f:ip2.txt .

其中,最后的.代表當前目錄,你可以自己指定。

3.提取cab所有文件

expand c:\cab\test.cab -f:* .

其中,-f:* 代表所有文件,可以使用通配符。最后的.代表當前目錄,你可以自己指定。

 如需轉載請注明出處。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM