7zip is a powerful and user-friendly package manager offering support for most popular file archives including ZIP, RAR, TAR, GZIP, 7z, and more. If you like you can also use the software without the GUI and access all features directly from the terminal. Discover best 7zip command line examples.
7z.exe is the command-line tool version of 7-Zip software allowing you to execute popular commands from system terminal. Use this app to compress, extract, test, rename, list, add, update archive files. This version works only with Windows. p7zip is the command line version of 7-Zip for Linux and Unix.
7z format provides a high compression ratio, open architecture, strong AES-256 encryption, option to use any compression or encryption method, supports files with sizes up to 16000000k GB, and Unicode file names. Integrated compression methods include LZMA, BCJ, Bzip2, Deflate, and PPMD.
The default compression method used by 7z format is LZMA. It features high compression ratio, variable dictionary size (up to 4 GB), small memory requirements for decompressing, support for multi-threading and P4's hyper-threading, and fas compression and decompression speeds.
7z.exe offers access to over 10 commands for file operations. Moreover, there are also switches that can be used with commands to set password, type of archive, create SFX, update files, etc.
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)
-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
-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
-ao{a|s|t|u} : set Overwrite mode
-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
-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
-x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
-y : assume Yes on all queries