用户登录
用户注册

分享至

7zip在dos命令行用法总结

  • 作者: 关爱八卦成长滴懂小姐
  • 来源: 51数据库
  • 2021-09-21

7zip功能很强大,你只要两个文件,7z.exe以及7z.dll就可以使用命令行工作了。

安装完7zip软件后,在其安装目录下找到7z.exe和7z.dll两个文件,将其复制到c:\windows\system32便可以在dos直接应用。

常用方式:

-o (set output directory) switch
specifies a destination directory where files are to be extracted.

this switch can be used only with extraction commands.

syntax-o{dir_path} {dir_path} this is the destination directory path. it's not required to end with a backslash. if you specify * in {dir_path}, 7-zip substitutes that * character to archive name.
example 7z x archive.zip -oc:\doc
extracts all files from the archive.zip archive to the c:\doc directory.

7z x *.zip -o*
extracts all *.zip archives to subfolders with names of these archives.

usage: 7za <command> [<switches>...] <archive_name> [<file_names>...]
[<@listfiles...>]

1. "a",添加文件
7z a -t7z files.7z *.txt

2. "d", 删除文件
7z d archive.zip *.bak -r
从zip文件中删除所有的*.bak文件

3. "e", 解压缩
7z e archive.zip

4. "l", 列出文件
7z l archive.zip

5. "t", 测试完整性
7z t archive.zip *.doc -r

6. "u", 更新
7z u archive.zip *.d

7. "x", 与e相同,但保留全路径

8. "m", 指定优化级别
compression switch: -mx0
what it means: don't compress at all.
is called "copy mode."

compression switch: -mx1
what it means: very low compression.
it is called "fastest" mode.

compression switch: -mx3
what it means: fast compression mode.
will set various parameters automatically.

compression switch: -mx5
what it means: same as above, but "normal."

compression switch: -mx7
what it means: "maximum" compression.

compression switch: -mx9
what it means: "ultra" compression.
(you probably want to use this.)

9. "-m"选项:
switch: -mfb
function: specifies # of fast bytes.
sometimes help with very "sparse" files.
don't bother.

switch: -mpass
function: number of passes for deflate compression.
don't bother with this.
automatically set with levels.

switch: -md
function: specifies dictionary size.
automatically set, so don't bother.

switch: -mmt
function: enable multithreading.
use if: you have quad-core and a really huge archive.
specify "on" or "off".
this may be enabled by default; check the help file.

10. "-t"选项
指定压缩文件类型
type switch: -t7z
format: 7z
example filename: archive.7z (default option)

type switch: -tgzip
format: gzip
example filename: archive.gzip
archive.gz

type switch: -tzip
format: zip
example filename: archive.zip (very compatible)

type switch: -tbzip2
format: bzip2
example filename: archive.bzip2

type switch: -ttar
format: tar
example filename: tarball.tar (unix and linux)

type switch: -tiso
format: iso
example filename: image.iso

type switch: -tudf
format: udf
example filename: disk.udf

7z a -tiso archive.iso
7z a -tudf archive.udf

7z: executable name
a: add to archive
-tiso or -tudf: format of archive to create
archive.iso or archive.udf: name of archive to create

10. 硬压缩
switch: -ms=on
function: enable solid mode.
this is the default so you won't often need this.

switch: -ms=off
function: disable solid mode.
this is useful when you need to update individual files.
will reduce compression ratios normally.

11. "-p"设定密码
7z a pw.7z *.txt -psecret

12. 其它选项:
switch: -ssc
function: specify case-sensitive mode.
useful for going between linux and windows.
default: -ssc- on windows (insensitive)
default: -scc on linux (sensitive)


switch: -ssw
function: compress locked files.
use if: you have problems with opening files.

switch: -w
function: set working directory.
use when you want to specify temp folders.

switch: -aoa
overwrite all destination files.

switch: -aos
skip over existing files without overwriting.
use this for files where the earliest version is most important.

switch: -aou
avoid name collisions.
new files extracted will have a number appending to their names.
(you will have to deal with them later.)

switch: -aot
rename existing files.
this will not rename the new files, just the old ones already there.
use when the new files are more important.

7z x test.zip -aoa

7z: use the 7-zip executable
x: use the extract command
test.zip: extract files from this archive

-aoa: overwrite all existing files. risky!

软件
前端设计
程序设计
Java相关