|
7-Zip是一款完全免費(fèi)而且開源的壓縮軟件,相比其他軟件有更高的壓縮比而且相對于WinRAR不會消耗大量資源。 命令格式 7z <command> [<switch>...] <base_archive_name> [<arguments>...] 7z +操作的名稱+ +操作的參數(shù)+ +打包文件名+ +要打包的文件+ +其他參數(shù)+ 壓縮 a (Add) command 添加文件到壓縮包中 7z a out1.zip in_dir\ //指定的是目錄名 把in_dir \之下的所有的文件和子目錄都添加到archive1.zip中。壓縮包中的所有文件名都會包含in_dir \前綴。解壓時得到的是in_dir目錄。壓縮的是目錄,解壓得到的也是目錄。 7z a out1.zip in_dir \* 和 7z a out1.zip in_dir \ 是一樣的。 7z a out3.zip .\ in_dir \* //指定的是文件名 把in_dir \之下的所有的文件和子目錄都添加到out3.zip中。壓縮包中的所有文件名都不包含in_dir \前綴。X命令解壓時直接得到各個文件和子目錄。 7z a out.zip -r 當(dāng)前目錄下的所有文件和子目錄打包到out.zip。 壓縮后刪除原文件 -sdel (Delete files after compression) switch 使用這個選項(xiàng)的作用就像是剪切。 7z a a.7z *.txt -sdel moves txt files from disk's directory to a.7z archive. 使用一個文件列表指定文件名 List file You can supply one or more filenames or wildcards for special list files (files containing lists of files). The filenames in such list file must be separated by new line symbol(s). For list files, 7-Zip uses UTF-8 encoding by default. You can change encoding using -scs switch. Multiple list files are supported. For example, if the file "listfile.txt" contains the following: My programs\*.cpp Src\*.cpp then the command 7z a -tzip archive.zip @listfile.txt adds to the archive "archive.zip" all "*.cpp" files from directories "My programs" and "Src". 指定打包文件格式 7z a -tzip archive.zip *.txt adds all *.txt files from current directory to zip archive archive.zip. 7z t -t7z.split archive.7z.001 tests all files in archive.7z.001. It also checks that archive is multivolume .7z archive. 7z x -t# sfxarchive.exe extracts sfxarchive.exe in parser mode. 7z x -tiso archive.iso extracts files from archive.iso open as ISO archive. 7z x -tudf archive.iso extracts files from archive.iso open as UDF archive. 如果沒有使用-t{archive_type}指定類型,那么7zip會使用擴(kuò)展名來決定打包類型。創(chuàng)建新的壓縮包,如果沒有指定類型,也沒有擴(kuò)展名,會默認(rèn)創(chuàng)建.7z類型的壓縮包。 輸出壓縮包中所有的文件名 l (List contents of archive) command Lists contents of archive,包括文件名,以及文件大小、類型等信息。 命令: 7za.exe l out3.zip 輸出: out3.zip里包含的是5個文件,而不是兩個文件和1一個子目錄,一個文件中不會包含目錄。只不過使用x命令解壓的時候可以創(chuàng)建dir1子目錄。 所以 dir1\11.txt 中的dir1 是“文件名前綴”,而不是目錄名。 從壓縮包中刪除文件 d (Delete) command Deletes files from archive. Example 7z d archive.zip *.bak -r deletes *.bak files from archive archive.zip. 解壓 解壓有兩個命令,e 和 x。e命令解壓的時候不會保持目錄結(jié)構(gòu),會把所有的文件都解壓到目的目錄下,不管這些文件是不是位于子文件夾。 x命令則會保存目錄結(jié)構(gòu)。以上面的out3.zip為例, 命令: 7za.exe x –oout_dir out3.zip out_dir中的文件結(jié)構(gòu): 命令:7za.exe e –oout_dir out3.zip out_dir中的文件結(jié)構(gòu): 子目錄dir是空目錄。 設(shè)置密碼 -p{password} 指定壓縮或者解壓時的密碼。 7z a archive.7z -psecret -mhe *.txt compresses *.txt files to archive.7z using password "secret". Also it encrypts archive headers (-mhe switch), so filenames will be encrypted. 注意有的參數(shù)是和格式關(guān)聯(lián)的,例如zip格式無法設(shè)置隱藏文件名,對zip格式使用 –mhe 參數(shù)就無法成功執(zhí)行。不同格式適用的不同命令參數(shù)見文檔。 7z x archive.zip -psecret extracts all files from archive.zip using password "secret". 計(jì)算哈希 7zip另一項(xiàng)非常有用的功能是計(jì)算文件的哈希。使用h (Hash) 命令計(jì)算文件的哈希。 語法格式: h [-scrc{Method}] [files] -scrc參數(shù)指定計(jì)算的方法,支持的方法有 CRC32, CRC64, SHA1, SHA256. 默認(rèn)是 CRC32. Examples 7z h a.txt calculates CRC32 for a.txt. 7z h -scrcsha256 a.iso calculates SHA256 for a.iso. 7z h * calculates CRC32 for all files in current folder and all subfolders. Notes 7-Zip shows hash values for each file, the sum of hash values and the sum that includes all hash values of data and all hash values for filenames. 7-Zip represents hash values for CRC32 and CRC64 as integer numbers in hex. 7-Zip represents hash values For SHA1 and SHA256 as sequence of bytes in hex. |
|
|