7-Zip Manual
Command line: commands
x (Extract with full paths) command
x (Extract with full paths) command
Extracts files from an archive with their full
paths in the current directory, or in an output directory if specified.
See the e (Extract) command description for more details.
Examples
7z x archive.zip
extracts all files from the archive
archive.zip to the current directory.
7z x archive.zip -oc:\soft *.cpp -r
extracts all *.cpp files from the archive
archive.zip to c:\soft folder.
Notes
7-Zip doesn't use the system wildcard parser. 7-Zip doesn't
follow the archaic rule by which *.* means any file. 7-Zip treats
*.* as matching the name of any file that has an extension. To process
all files, you must use a * wildcard.
Switches that can be used with this command
-ai (Include archives)
-an (Disable parsing of archive_name)
-ao (Overwrite mode)
-ax (Exclude archives)
-bb (Set output log level)
-i (Include)
-m (Method)
-o (Set Output Directory)
-p (Set Password)
-r (Recurse)
-si (use StdIn)
-sni (Store NT security information)
-sns (Store NTFS alternate Streams)
-so (use StdOut)
-spf (Use fully qualified file paths)
-spm (Require path separator mark for directory path)
-stx (Exclude archive type)
-t (Type of archive)
-x (Exclude)
-y (Assume Yes on all queries)
-scrc (Set hash method)
See also
Commands:
e (Extract)
Notes from this site
Not part of the 7-Zip manual. Written by this site; examples checked with 7-Zip 26.04.
Quick examples
Use x unless you want every file in one flat folder (that is e , which drops folder names). On Linux and macOS the official console binary is 7zz; on Windows it is 7z. The vendor example uses -oc:\soft, which is Windows-only. Quote wildcards.
7zz l -slt archive.zip
7zz x archive.zip -o/path/to/dest '*.cpp' -r
7zz x archive.zip -o./archive/
7zz x archive.zip docs/readme.txt -o/path/to/dest
7zz x archive.zip 'docs/*' -o/path/to/dest
7zz x '*.zip' '-o*'
7zz x archive.7z -o/path/to/dest -y -p"$PW"
7zz x file.tar.gz -so | 7zz x -si -ttar -o/path/to/dest
List first with l ; with -slt each Path = line is the exact stored path to type for a single file or folder. The third command puts everything in a new folder named archive, which keeps a badly packed or untrusted archive from scattering files into a folder you care about; -o creates the folder if needed. The fourth extracts one file and the fifth only the docs folder; both keep the stored path, so you get /path/to/dest/docs/readme.txt. The sixth extracts each archive into its own folder named after the archive. The seventh is for scripts: -y answers yes to prompts. -p"$PW" takes the password from a shell variable, but a password on the command line is visible in ps and shell history. The last line unpacks a .tar.gz in one step.
Existing files and failures
Choose what happens to existing files instead of using -y alone: -aos skips them, -aou renames the new ones (same_1.txt), -aoa overwrites.
Plain -p asks for the password. With no terminal (cron, input from /dev/null) it prints "Enter password:" and ends with exit code 255, so pass the password in a script as above. Other exit codes: exit codes .
Common mistakes
Putting a space after -o. Write -o/path/to/dest.
Expecting a .tar.gz to unpack in one plain step. The first x gives a .tar; run x on it again, or use the pipe above.
Leaving *.zip unquoted when several zip files are present: the shell turns it into one.zip two.zip, 7-Zip reads two.zip as a name to extract from one.zip, and nothing is extracted ("Files: 0").
Related pages