Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following folder structure

  • root
    • folder1
    • folder2
    • folder3
    • 7za.exe

I want to run the 7-zip command line tool to zip up all the files in folder1 to a zip file called

Running the following

7za.exe a -tzip folder1\\*.*

produces a zip file as expected. However, when I open the zip file, it has a folder in it called "folder1", and inside that I have all the files listed. I don't want the folder name added to the zip folder, i.e. add all the files in a "Flat" file format.

I also don't want to recursively run the command line tool for each individual file. Is there a switch that provides this functionality?

share|improve this question
Can you cd into folder1 and 7za.exe a -tzip ..\ *.*? – zpletan Sep 26 '11 at 17:09
up vote 48 down vote accepted

From the 7-Zip Help file:

a (Add) command

Adds files to archive.


7z a subdir\

adds all files and subfolders from folder subdir to archive The filenames in archive will contain subdir\ prefix.

7z a .\subdir\*

adds all files and subfolders from folder subdir to archive The filenames in archive will not contain subdir\ prefix.

cd /D c:\dir1\

7z a c:\ dir2\dir3\

The filenames in archive c:\ will contain dir2\dir3\ prefix, but they will not contain c:\dir1\ prefix.

So the command you'd want would be: 7za.exe a .\folder1\*

Also, pay attention to 7-Zip's handling of wildcards. It doesn't treat *.* as "all files" -- it means "all files with a period in the filename." Extension-less files will be missed. If you really want all files, just use * instead.

Finally, the -tzip parameter isn't needed if the archive filename ends in .zip. 7-Zip is smart enough to figure out which format you want in those cases. It's only required when you want a custom extension (e.g. 7za.exe a -tzip foo.xpi <files> for a Mozilla Add-on).

share|improve this answer
Worked like a charm... Thanks. – gg. Sep 27 '11 at 8:36
THANK YOU. i have a love/hate relationship with 7zip. It's great but the command line interface kills me everytime. – Jugglingnutcase Feb 8 '13 at 19:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.