7z压缩与解压命令
在寫很多工具的時(shí)候,可能會(huì)用到7z命令來進(jìn)行壓縮與解壓操作。這里記錄二個(gè)比較常用的操作:壓縮、解壓。
?
在dos窗口下輸入7z命令,會(huì)顯示7z的使用參數(shù)詳情:
7-Zip 9.10 beta? Copyright (c) 1999-2009 Igor Pavlov? 2009-12-22
Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
?????? [<@listfiles...>]
<Commands>
? a: Add files to archive
? b: Benchmark
? d: Delete files from archive
? e: Extract files from archive (without using directory names)
? l: List contents of archive
? t: Test integrity of archive
? u: Update files to archive
? x: eXtract files with full paths
<Switches>
? -ai[r[-|0]]{@listfile|!wildcard}: Include archives
? -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
? -bd: Disable percentage indicator
? -i[r[-|0]]{@listfile|!wildcard}: Include filenames
? -m{Parameters}: set compression Method
? -o{Directory}: set Output directory
? -p{Password}: set Password
? -r[-|0]: Recurse subdirectories
? -scs{UTF-8 | WIN | DOS}: set charset for list files
? -sfx[{name}]: Create SFX archive
? -si[{name}]: read data from stdin
? -slt: show technical information for l (List) command
? -so: write data to stdout
? -ssc[-]: set sensitive case mode
? -ssw: compress shared files
? -t{Type}: Set type of archive
? -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
? -v{Size}[b|k|m|g]: Create volumes
? -w[{path}]: assign Work directory. Empty path means a temporary directory
? -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
? -y: assume Yes on all queries
?
必選參數(shù):最常用的命令有a(壓縮)、x(解壓),其它的命令諸如刪除,解壓出來不保留目錄結(jié)構(gòu)這種,一般情況下都用不到。
可選參數(shù):最常用的就是-t{Type}
Type默認(rèn)值為7z,還有其它的如:
| Type | Format | Example filename |
| -t7z | 7Z | archive.7z(默認(rèn)) |
| -tgzip | GZIP | archive.gzip,archive.gz |
| -tzip | ZIP | archive.zip(兼容) |
| -tbzip2 | BZIP2 | archive.bzip2 |
| -ttar | TAR | tarball.tar(Unix/Linux) |
| -tiso | ISO | image.iso(可能不支持) |
| -tudf | UDF | disk.udf |
常用的就是-t{Type}以及-r、-o、-y
?
解壓命令:7z x -tzip -y xx-13.zip (解壓到當(dāng)前目錄,如需改變輸出目錄,需要附加使用-o)
壓縮命令:7z a -tzip -r xx.zip a\* b\*
將目錄a、目錄b,壓縮成一個(gè)xx.zip
?
更多參數(shù)的詳情,可以參考這里:http://www.dotnetperls.com/7-zip-examples
?
在Windows的64位操作系統(tǒng)下,除需要7z.exe外,還需要7z.dll,我將他們打包為一個(gè)zip文件,否則你執(zhí)行命令的時(shí)候可能會(huì)遇到上面的錯(cuò)誤。你可以從這里直接下載>>
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
- 上一篇: [设计模式]设计模式之禅关于迪米特法则
- 下一篇: MyBatis知多少(22)MyBati