- 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.txte (Extract)
Extracts all files to the same directory, ignoring paths.Example:
file/data.txt → output/data.txtCommon Options
Name of the archive to extract. 7-Zip auto-detects archive type.
Specific files or patterns to extract. If omitted, extracts all files.Example:
*.txt or documents/report.pdfSet output directory. No space between
-o and the path.Example: -o/home/user/output or -oC:\OutputProvide password for encrypted archives. Omit password to be prompted.Example:
-pMyPassword or -p (prompts)Assume Yes on all queries (overwrite without prompting).
Set overwrite mode:
a- Overwrite all existing filess- Skip existing filest- Auto-rename extracting fileu- Auto-rename existing file
-aoa (overwrite all)Set archive type (usually auto-detected).Example:
-t7z or -tzipRecurse subdirectories (enabled by default for archives).
Exclude files by pattern.Example:
-x!*.tmp -x!*.bakInclude only files matching pattern.Example:
-i!*.txtWrite data to stdout (for piping).
Read archive from stdin.
Eliminate duplication of root folder for extract command.
Use fully qualified file paths (include drive letter on Windows).
Store hard links as links (extract as links, not copies).
Store symbolic links as links (extract as links, not file contents).
Store NT security information (Windows).
Store NTFS alternate streams (Windows).
Examples
Extract archive with full paths
Extract to specific directory
Extract without directory structure
Extract password-protected archive
Extract specific files
Extract files by pattern
Extract and overwrite without prompting
Extract and skip existing files
Extract and auto-rename new files
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
Extract nested archives
Test before extracting
Advanced Examples
Extract with progress to stderr
Extract preserving timestamps
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:
| Mode | Switch | Behavior |
|---|---|---|
| Overwrite All | -aoa | Replace all existing files |
| Skip | -aos | Keep existing files, skip extraction |
| Auto-rename (extracting) | -aot | Rename newly extracted files |
| Auto-rename (existing) | -aou | Rename existing files |
Interactive Prompt (default)
Without-ao or -y, 7-Zip prompts for each file:
Working with Different Archive Types
ZIP archives
TAR.GZ archives
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.Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success (no errors) |
| 1 | Warning (non-fatal error) |
| 2 | Fatal error |
| 7 | Command line error |
| 8 | Not enough memory |
Related Commands
- List Command (l) - View archive contents
- Test Command (t) - Test archive integrity
- Add Command (a) - Create archives