116
29
Any idea how to exclude a wild-carded path(s) from a command-line 7zip command?
I'm doing something like this:
7z.exe a -t7z archive.7z FolderToArchive\ -mx0
and would like to exclude any \bin\*.*
or \obj\*.*
folders found underneath "FolderToArchive".
To exclude files, you can use the -x
parameter. The help file gives this example for using -x
:
7z a -tzip archive.zip *.txt -x!temp.*
That's great for excluding a file. But, again, I would like to exclude a wildcard-specified folder. Under my "FolderToArchive" there are multiple folders, under those folders there may or may not be bin\
and obj\
folders. I would like to not include these in the archive.
I've tried patterns like
-x!bin\*
-x!bin\*.*
-x!\bin\*
-x!\bin\*.*
-x!\\bin\\*
-x!\\bin\\*.*
None seem to exclude the bin\
folder. Is this simply a limitation of 7zip?
6Also, if this is in a Linux/Unix command line, you may need to enclose in single quotes, to not add pre-processing by the shell, e.g.
'-x!$RECYCLE.BIN'
to exclude the Recycle bin of an external drive. – thanosa75 – 2017-04-03T11:29:53.2071what is -mx0 good for? – Gerfried – 2019-10-30T17:12:54.317
6For everyone else: if you want to ignore only the files in the root directory, use
-xr0!*.zip
- at least I couldn't get it to work without ther0
. – Oliver – 2013-02-23T09:46:49.697