配置
- 下載安裝7z
- 配置環境變量
- win鍵按下,搜索
env
,打開編輯環境變量,選擇環境變量 - 在系統變量下的
path
中添加你的7zip安裝位置,如C:\Program Files\7-Zip\
- 一路OK確認,關閉窗口
- win鍵按下,搜索
- 檢查可用性
- 打開cmd,輸入
7z
命令,查看是否可用
- 打開cmd,輸入
文檔
這里只列了一部分,不想看英語的請忽略吧~
7z -h
Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
<Commands>
a : Add files to archive
b : Benchmark
d : Delete files from archive
e : Extract files from archive (without using directory names)
h : Calculate hash values for files
i : Show information about supported formats
l : List contents of archive
rn : Rename files in archive
t : Test integrity of archive
u : Update files to archive
x : eXtract files with full paths
<Switches>
...
壓縮
7z a -t[format] archive_name file_name
- 參數
a
表示【加】進壓縮包 - -t[format] 表示壓縮包格式,自己指定,如
-tzip
為 zip 壓縮包 - archive_name 壓縮包名字
- file_name 文件名,帶擴展名,可以一個一個羅列出來,也可以用通配符,如
*.txt
匹配所有txt文件*.*
匹配所有文件
舉例
將當前目錄下所有 docx 文件打包壓縮,壓縮包名為 archive_name.zip
7z a -tzip archive_name.zip *.docx
解壓
- 參數有兩種:一個是e,一個是x
- 區別:e解壓出來的沒有文件夾結構,x解壓出來的有文件夾結構
- 一般都用 x
下面說明 x
的語法
7z x -o[output_dir] archive_name
- -o[output_dir] 輸出文件夾,舉例:-otest 表示當前目錄下的 test 文件夾下,不寫就是當前目錄
- 注意輸出 -o 和文件夾名稱要連着寫,中間沒有空格
舉例
解壓縮archive.zip包到當前目錄下的source_file文件夾下
7z x -osource_file archive.zip
查看壓縮包有什么文件
l
表示列出所有文件 (是英文字母 L)
7z l test.zip