7z压缩与解压命令

简介: 在写很多工具的时候,可能会用到7z命令来进行压缩与解压操作。这里记录二个比较常用的操作:压缩、解压。   在dos窗口下输入7z命令,会显示7z的使用参数详情: 7-Zip 9.10 beta  Copyright (c) 1999-2009 Igor Pavlov  2009-12-22 Usage: 7z [.

在写很多工具的时候,可能会用到7z命令来进行压缩与解压操作。这里记录二个比较常用的操作:压缩、解压。

 

在dos窗口下输入7z命令,会显示7z的使用参数详情:

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

 

必选参数:最常用的命令有a(压缩)、x(解压),其它的命令诸如删除,解压出来不保留目录结构这种,一般情况下都用不到。

可选参数:最常用的就是-t{Type}

Type默认值为7z,还有其它的如:

Type Format Example filename
-t7z 7Z archive.7z(默认)
-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 (解压到当前目录,如需改变输出目录,需要附加使用-o)

压缩命令:7z a -tzip -r xx.zip a\* b\*

将目录a、目录b,压缩成一个xx.zip

 

更多参数的详情,可以参考这里:http://www.dotnetperls.com/7-zip-examples

 

在Windows的64位操作系统下,除需要7z.exe外,还需要7z.dll,我将他们打包为一个zip文件,否则你执行命令的时候可能会遇到上面的错误。你可以从这里直接下载>>

目录
相关文章
|
前端开发 算法 API
直接在前端做 zip 压缩/解压
前段时间研究前端是如何解析 excel 表格的时候了解到 jszip 这个库,可以直接在前端对 zip 包进行压缩和解压缩,今天稍微水一篇。
|
2月前
|
Linux
linux命令行打包、压缩及解压缩
linux命令行打包、压缩及解压缩
10 0
|
5月前
|
算法 编译器 API
C++ MiniZip实现目录压缩与解压
Zlib是一个开源的数据压缩库,提供了一种通用的数据压缩和解压缩算法。它最初由`Jean-Loup Gailly`和`Mark Adler`开发,旨在成为一个高效、轻量级的压缩库,其被广泛应用于许多领域,包括网络通信、文件压缩、数据库系统等。其压缩算法是基于`DEFLATE`算法,这是一种无损数据压缩算法,通常能够提供相当高的压缩比。在Zlib项目中的`contrib`目录下有一个`minizip`子项目,minizip实际上不是`zlib`库的一部分,而是一个独立的开源库,用于处理ZIP压缩文件格式。它提供了对ZIP文件的创建和解压的简单接口。minizip在很多情况下与`zlib`一起使用
154 0
C++ MiniZip实现目录压缩与解压
|
9月前
|
Linux
Linux常用的压缩与解压
1、gzip压缩解压 因为都是系统自带的我们不需要安装; ls 看一下目录当前的文件,创建一个 touch 123.txt 文件; 原文件消失,压缩解压 gzip 进行压缩,(“ gzip 123.txt ”),这样就压缩完毕了; gzip 进行解压,(“ gzip -d 123.txt.gz”),这样就解压完毕了; 原文件保留,gzip -k 123.txt、gzip -dk 123.txt.gz ; 2、bzip2压缩解压 因为都是系统自带的我们不需要安装; 原文件消失,压缩解压 bzip2进行压缩,(“ bzip2 123.txt ”),这样就压缩完毕了; bzip2 进行解压,(“
58 0
|
Linux
linux命令之tar 解压 压缩
本篇内容记录了有关tar 解压 压缩的相关操作。
230 0