Extract Without Subdirectories in 7-Zip CLI
This guide explains how to extract files from an archive directly
into a single folder without preserving or creating the internal
subdirectories using the 7-Zip Command Line Interface (CLI). By using
the extraction (e) command instead of the standard
extract-with-paths (x) command, you can flatten the entire
directory structure of any supported archive format.
The Basic Command
To extract all files into the current working directory while
stripping away the internal folder paths, use the e
command:
7z e archive.zipUnlike 7z x, which recreates the directory tree stored
inside the archive, 7z e extracts every file into the root
of your target directory.
Extracting to a Specific Directory
To extract the files without subdirectories into a target location
other than your current working directory, use the -o
switch.
Important: Do not put a space between the
-o switch and the target directory path.
7z e archive.zip -o"C:\DestinationFolder"On Linux or macOS:
7z e archive.tar.gz -o/path/to/destinationHandling Duplicate File Names
Because flattening an archive places files from different subfolders
into the same destination, filename collisions can occur. You can
control how 7-Zip handles duplicate file names using the
-ao (Overwrite Mode) switch:
- Overwrite all existing files:
7z e archive.zip -o"C:\DestinationFolder" -aoa - Skip extracting existing files:
7z e archive.zip -o"C:\DestinationFolder" -aos - Automatically rename extracted files (e.g.,
file_1.txt):
7z e archive.zip -o"C:\DestinationFolder" -aou
Complete Example
To extract an archive named data.zip to a folder named
output, ignore all internal folders, and automatically
rename any conflicting files, run:
7z e data.zip -ooutput -aou