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 know that the 7-zip command to add a folder to an archive is, e.g.:

"c:\program files\7-zip\7z" a testArchive.zip c:\myFolder

And the command to add only files of a certain extension to an archive is, e.g.:

"c:\program files\7-zip\7z" a testArchive.zip c:\myFolder\*.jpg -i!c:\myFolder\*.pdf

How do I add a folder to an archive containing only files of a certain extension? I tried:

"c:\program files\7-zip\7z" a testArchive.zip c:\myFolder\ -i!c:\myFolder\*.jpg -i!c:\myFolder\*.pdf

but that just added all the files in the folder, not just the .jpg and .pdf. What's more, it also added subfolders, which I didn't want.

Is there a way to use the -x switch so that I can say, "add all files except those that are not these extensions, and don't add any subfolders"?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Your command told 7z to add the data in myFolder, then also to add stuff in myFolder that was a jpg, then that which is a pdf. You can just use:

"c:\program files\7-zip\7z" a testArchive.zip -i!c:\myFolder\*.jpg -i!c:\myFolder\*.pdf

and that will pick up the correct files through the inclusion filters.

share|improve this answer

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.