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 add any txt file under a given path using 7-Zip.

Looking at the help I tried this:

7za a  -ir!*.txt bla.7z c:\initial\path

This ended up including every single file, txt or not.

Looking at this question I tried to do this:

7za a  -ir!.\*.txt bla.7z c:\initial\path

This ended up giving me this awkward message:

Error:
Duplicate filename:
c:\initial\path\CLI\0003\readme.txt
c:\initial\path\CLI\0003\readme.txt

Interestingly the -xr option works fine for me. For example if I try:

7za a  -xr!*.txt bla.7z c:\initial\path

every file but the txts are included.

share|improve this question
up vote 3 down vote accepted

Try 7z a bla.7z -r c:\initial\path\*.txt

You don't need to use the -i switch unless you want to include more than one set of wildcards. In that case, you'd want to you'll want to use multiple -i for each set of wildcards on the same command line. But that is a big big pain in the rear and not recommendation.

It is better to output the file paths into a listfile and feed the list of paths into 7z.

share|improve this answer

You must log in to answer this question.

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