Zipping everything in directory with 7z except one file or one file type

7zip, cmd, zip

Solution

Per the 7za command-line help, you use the -x switch to do this:

-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames

To exclude the file foo.txt you would add:

-x!foo.txt

To exclude all .html files (*.html) you would add:

-x!*.html

You can add multiple -x entries to exclude multiple filenames and/or wildcards in one zip command. Adding the following will exclude foo.txt and *.html:

-x!foo.txt -x!*.html

So with your example, this would add all files to files.zip EXCEPT files named "FILENAME" or that matched the *.extension wildcard:

7z a -tzip files.zip * -x!FILENAME -x!*.extension

Problem

i'd like to zip everything except one file ``` 7z a -tzip files.zip * ``` this will zip all the files in my current directory.. is there a way I can tell it to not zip one file or one file type ?

Original source