HỖ TRỢ
02516-544-809
1900-636-507
 
Giờ làm việc
Sáng 07h30 đến 12h00
Chiều 13h30 đến 17h00
WD0009 | 7zip command line examples

Usage: 7z <@command> [<@switches>...] <@archive_name> [<@file_names>...] [@listfile]

7-Zip command line add files to archive:

Compress folder Program Files to c:\filename.7z

7z.exe a c:\filename.7z "c:\Program Files"

7-Zip command line compress:

Compress folder, and subfolders in Program to c:\filename.7z

7z.exe a -r c:\filename.7z "c:\Program"

7-Zip command line pack all files:

Compress all JPG files in folder and subfolders from folder1

7z.exe a -r c:\filename.zip c:\folder1\*.jpg

7zip command line extract:

Extract all files from archive.zip

7z.exe e archive.zip

7zip command to extract specific file type:

Extract all .doc files from archive.zip to folder c:/kuba

7z.exe e archive.zip -o c:\kuba *.doc -r

7-Zip command line to calculate a hash (CRC32, CRC64, SHA1, SHA256, BLAKE2sp):

Calculate SHA256 hash value for file.iso.

7z.exe h -scrcsha256 file.iso

7-Zip command line benchmark:

Start benchmark.

7z.exe b

7-Zip command line list:

Show list of all files in the archive.

7z.exe l archive.zip

7-Zip command line rename:

Rename old.txt to new.txt and 101.txt to folder\101new.txt

7z.exe rn a.7z old.txt new.txt 101.txt folder\101new.txt

7-Zip commands quick reference

-a (Add)
-b (Benchmark)
-d (Delete)
    7z d archive.zip *.bak -r
    deletes *.bak files from archive archive.zip
-e (Extract)
-h (Hash)
-i (Show information about supported formats)
-l (List)
-rn (Rename)
-t (Test)
-u (Update)
-x (eXtract with full paths)

7-Zip switches for use with commands

-- : Stop switches and @listfile parsing
-ai[r[-|0]]{@listfile|!wildcard} : Include archives
    7z t -an -air!*.7z
    tests *.7z archives in current directory and all it's subdirectories
-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
-ao{a|s|t|u} : set Overwrite mode
    -aoa    Overwrite All existing files without prompt.
    -aos    Skip extracting of existing files.
    -aou    aUto rename extracting file (for example, name.txt will be renamed to name_1.txt).
    -aot    auto rename existing file (for example, name.txt will be renamed to name_1.txt).
    7z x test.zip -aoa {extracts all files from test.zip archive and overwrites existing files without any prompt}
-an : disable archive_name field
-bb[0-3] : set output log level
-bd : disable progress indicator
-bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
-bt : show execution time statistics
-i[r[-|0]]{@listfile|!wildcard} : Include filenames
-m{Parameters} : set compression Method
-mmt[N] : set number of CPU threads
-mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)
-o{Directory} : set Output directory
-p{Password} : set 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.
    7z x archive.zip -psecret
    extracts all files from archive.zip using password "secret".

-r[-|0] : Recurse subdirectories
-sa{a|e|s} : set Archive name mode
-scc{UTF-8|WIN|DOS} : set charset for for console input/output
-scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files
-scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands
-sdel : delete files after compression
-seml[.] : send archive by email
-sfx[{name}] : Create SFX archive
-si[{name}] : read data from stdin
-slp : set Large Pages mode
-slt : show technical information for l (List) command
-snh : store hard links as links
-snl : store symbolic links as links
-sni : store NT security information
-sns[-] : store NTFS alternate streams
-so : write data to stdout
-spd : disable wildcard matching for file names
-spe : eliminate duplication of root folder for extract command
-spf : use fully qualified file paths
-ssc[-] : set sensitive case mode
-sse : stop archive creating, if it can't open some input file
-ssw : compress shared files
-stl : set archive timestamp from the most recently modified file
-stm{HexMask} : set CPU thread affinity mask (hexadecimal number)
-stx{Type} : exclude archive type
-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
    7z a -tzip archive.zip *.cpp -wc:\temp
    adds *.cpp files to the archive.zip archive, creating a temporary archive in c:\temp folder
-x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
-y : assume Yes on all queries
0
Giỏ hàng
Chat ngay
Hotline02516544809
Chat ngay