设为首页 加入收藏

TOP

cmd实现cab文件的压缩与解压
2019-08-26 07:29:30 】 浏览:31
Tags: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:* 代表所有文件,可以使用通配符。最后的.代表当前目录,你可以自己指定。

 如需转载请注明出处。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Windows迁移打印机与打印队列 下一篇windowns10安装httpd

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目