Skip to main content
The extract commands extract files from archives. 7-Zip provides two extraction commands:
  • x - eXtract files with full paths
  • e - Extract files without directory structure

Syntax

Difference Between x and e

x (eXtract with paths)

Extracts files with full directory structure preserved.Example: file/data.txt → output/file/data.txt

e (Extract)

Extracts all files to the same directory, ignoring paths.Example: file/data.txt → output/data.txt

Common Options

string
required
Name of the archive to extract. 7-Zip auto-detects archive type.
string
Specific files or patterns to extract. If omitted, extracts all files.Example: *.txt or documents/report.pdf
string
Set output directory. No space between -o and the path.Example: -o/home/user/output or -oC:\Output
string
Provide password for encrypted archives. Omit password to be prompted.Example: -pMyPassword or -p (prompts)
flag
Assume Yes on all queries (overwrite without prompting).
string
Set overwrite mode:
  • a - Overwrite all existing files
  • s - Skip existing files
  • t - Auto-rename extracting file
  • u - Auto-rename existing file
Example: -aoa (overwrite all)
string
Set archive type (usually auto-detected).Example: -t7z or -tzip
flag
Recurse subdirectories (enabled by default for archives).
string
Exclude files by pattern.Example: -x!*.tmp -x!*.bak
string
Include only files matching pattern.Example: -i!*.txt
flag
Write data to stdout (for piping).
flag
Read archive from stdin.
flag
Eliminate duplication of root folder for extract command.
flag
Use fully qualified file paths (include drive letter on Windows).
flag
Store hard links as links (extract as links, not copies).
flag
Store symbolic links as links (extract as links, not file contents).
flag
Store NT security information (Windows).
flag
Store NTFS alternate streams (Windows).

Examples

Extract archive with full paths

Output:

Extract to specific directory

Extract without directory structure

All files extracted to current directory, paths discarded.

Extract password-protected archive

Prompts:
Or provide password directly:

Extract specific files

Extract files by pattern

Extract and overwrite without prompting

Extract and skip existing files

Extract and auto-rename new files

Creates: file.txt, file_1.txt, file_2.txt, etc.

Extract excluding certain files

Extract only specific file types

Extract to stdout (piping)

Extract multi-volume archive

Automatically finds and uses all volumes (.001, .002, .003, etc.)

Extract nested archives

Test before extracting

Advanced Examples

Extract with progress to stderr

Extract preserving timestamps

(Timestamps preserved by default)

Extract case-sensitive (Linux)

Extract from stdin

Extract multiple archives

Extract with full paths including drive (Windows)

Overwrite Modes

The -ao switch controls behavior when extracted files already exist:

Interactive Prompt (default)

Without -ao or -y, 7-Zip prompts for each file:

Working with Different Archive Types

ZIP archives

TAR.GZ archives

Or extract in one step:

RAR archives

ISO images

Split archives

The x command is recommended for most use cases as it preserves the directory structure. Use e only when you specifically want all files in one directory.
Using e (extract without paths) can cause file name conflicts if the archive contains files with the same name in different directories. 7-Zip will prompt to overwrite unless -y or -ao is used.
To preview archive contents before extracting, use the list command:

Exit Codes