Compress Files Without Paths in 7-Zip

By default, 7-Zip often includes directory hierarchies when creating archives, preserving folder structures you may not want. This guide explains how to compress files without storing relative directory paths using both the 7-Zip Graphical User Interface (GUI) and the Command Line Interface (CLI), ensuring all compressed files sit directly in the root of the archive upon extraction.

Method 1: Using the 7-Zip GUI

The simplest way to avoid storing folder paths in the GUI is to select the files themselves rather than the folder containing them.

  1. Open the folder containing the files you want to archive.
  2. Select all the individual files (press Ctrl + A).
  3. Right-click the selected files, hover over 7-Zip, and select Add to archive....
  4. Configure your compression settings (such as Archive format and Compression level).
  5. Click OK.

Because you selected the files directly instead of the parent folder, 7-Zip stores only the file names without any preceding folder paths.

Method 2: Using the 7-Zip File Manager

If you prefer using the dedicated 7-Zip application:

  1. Open 7-Zip File Manager.
  2. Navigate inside the folder containing your target files.
  3. Highlight the files you wish to compress.
  4. Click the green + Add button on the toolbar.
  5. Choose your archive name and settings, then click OK.

Method 3: Using the Command Line (CLI)

When using 7z.exe, relative paths are determined by your current working directory. If you specify a path in the command, 7-Zip includes that path in the archive. To prevent this, switch to the target directory before running the compression command.

Windows Command Prompt

cd /d "C:\path\to\your\folder"
7z a "C:\path\to\output\archive.zip" *

Flattening Subdirectories

Unlike some archivers, 7-Zip does not feature a single native switch to recursively flatten all subdirectories into the root of an archive. If you have files inside multiple subfolders and want all of them placed into the archive without their folder paths, use a batch loop to add them individually:

for /r "C:\path\to\source" %i in (*) do 7z a "C:\path\to\output\archive.zip" "%i"

In a .bat script, use %%i instead of %i. This command traverses all subdirectories and feeds only the individual file references to 7-Zip, resulting in an archive where every file exists in the root without any directory paths.