Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 want to compress the folder C:\Temp but without a specific subfolder (e.g. C:\Temp\test). How can I do that with 7zip?

I've come up with the following command:

c:\Temp>7zip a -t7z test.7z c:\temp\ -mx0 -x!c:\temp\test\*

but it dos not work since the output is:

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Scanning

Updating archive test.7z


Compressing  Temp\admin.PNG
Compressing  Temp\test\admin2.PNG   <<<<<< this file should not be added to the archive
Compressing  Temp\first.txt
share|improve this question
    
Maybe what's missing is the -r (recursive) flag. The default is not to recurse subdirectories. – Doktoro Reichard Dec 2 '13 at 11:36
    
The switch -r did not help. – Martin Vseticka Dec 2 '13 at 13:57

As tested on my system:

7zip a -t7z -mx0 -x!test\* test.7z c:\temp\ 

If you're in the source directory, the files are stored with relative paths, so the test folder looks like test\file1.txt, not c:\temp\test\file1.txt.

Please note, with the -mx0 switch, you're not compressing the files, only copying them fullsize into the archive.

share|improve this answer
    
Thank you. I made it work with the command 7zip a -t7z test.7z c:\temp\ -mx0 -x!Temp\test\*. Note the part Temp\test\* that differs from your command. I do not know why your command does not work for me. – Martin Vseticka Dec 2 '13 at 20:13
    
I used -mx0 switch on purpose. I just needed to do a backup on my server and I wanted minimal impact on CPU of my server. – Martin Vseticka Dec 2 '13 at 20:25
    
I updated this answer, my personal experience was that I needed to specify more of the relative path in order for this to work as well – Taegost Nov 11 '15 at 11:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .