Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 2 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
add comment

Your Answer

 
discard

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.