文章目录
一、7z 文件压缩格式简介二、7z 命令使用说明1、压缩命令2、解压命令三、7z 命令示例1、配置 7z 命令环境变量2、压缩3、解压缩四、参考资料一、7z 文件压缩格式简介
7z 文件压缩格式 , 压缩比很高 , 压缩时可以选择多种压缩算法 , 该算法比 zip , tar , rar 等压缩格式的压缩比率更高 , 得到的压缩后的文件最小 ;
7-Zip 简介 :开源压缩软件 , 压缩比率高 , 压缩时消耗的资源也多 ; 支持 7z , xz , bzip2 , gzip , tar , zip , wim 等压缩格式 , 不支持 rar 格式 ( 这个还在专利保护期内 ) ;
7-Zip 官网 :https://www.7-/
7-Zip 软件压缩比率 , 比 WinZip , WinRAR , 等压缩任何格式都要高 , 包括 zip 和 rar 格式 ;
从压缩时间进行分析 , 使用快速压缩模式 , 7-Zip 比其他软件都快 , 如果使用高压缩比率模式 , 7-Zip 压缩比其它压缩工具慢 ;
二、7z 命令使用说明
1、压缩命令
7z 压缩命令 :
7z a outputFile inputFile -mx=compressDegree -tcompressType
其中a
代表 add 的含义 ;
outputFile
是输出文件 ;
inputFile
表示输入文件 ;
-mx=compressDegree
用于设置压缩等级 , compressDegree 取值范围 {0,1,5,7,9}\{ 0 , 1, 5, 7,9 \}{0,1,5,7,9} ;
-tcompressType
表示压缩类型 ,-t7z
表示压缩格式为 7z ,-tzip
表示压缩格式是 zip 格式 ;
压缩等级含义 :
000 : 不压缩 , 只存储 ;111 : 快速压缩 ;555 : 正常压缩 ;777 : 最大压缩 ;999 : 极限压缩 ;
2、解压命令
7z 解压缩命令 :
7z x [输入文件] -o[输出目录]
输入文件指的就是压缩文件 ;
输出目录就是将压缩文件解压到哪 ;
注意 : -o 与输出目录之间没有空格 ;
三、7z 命令示例
1、配置 7z 命令环境变量
将 7zip 安装目录 A:\Program Files\7-Zip 配置到 Path 环境变量中 ;
配置环境变量 ;
配置完成后 , 可以在任意目录中调用 7z 命令了 ;
2、压缩
7z 压缩命令 :将本目录压缩到 string.7z 压缩包中 , 压缩等级设置为极限压缩 ;
7z a string.7z . -mx=9
命令行输出 :
D:\develop\7zip>7z a string.7z . -mx=97-Zip 19.00 (x64) : Copyright (c) 1999- Igor Pavlov : -02-21Scanning the drive:1 file, 23361 bytes (23 KiB)Creating archive: string.7zAdd new data to archive: 1 file, 23361 bytes (23 KiB)Files read from disk: 1Archive size: 5438 bytes (6 KiB)Everything is OkD:\develop\7zip>
压缩结果 :23KB 的 XML 文本文件被压缩层 6KB ;
3、解压缩
7z 解压缩命令 :将 string.7z 解压 , 输出到 output 目录中 ;
7z x string.7z -ooutput
命令行输出 :
D:\develop\7zip>7z x string.7z -ooutput7-Zip 19.00 (x64) : Copyright (c) 1999- Igor Pavlov : -02-21Scanning the drive for archives:1 file, 5438 bytes (6 KiB)Extracting archive: string.7z--Path = string.7zType = 7zPhysical Size = 5438Headers Size = 130Method = LZMA2:24kSolid = -Blocks = 1Everything is OkSize: 23361Compressed: 5438D:\develop\7zip>
解压结果 :string.7z 解压到了 output 目录中 ;
四、参考资料
参考资料 :
7-Zip 官网 :https://www.7-/