How do I exclude hidden directories when creating an archive using 7zip's command line version?
I tried -x!".*"
, but that didn't work.
How do I exclude hidden directories when creating an archive using 7zip's command line version?
I tried -x!".*"
, but that didn't work.
You need to add the r
("recurse") flag to the -x
option if you want it to match files inside subdirectories.
For example, the following creates an archive from the whole directory tree under folder/
except for any files that start with a dot:
7z a -xr'!.*' archive.7z folder/
I had the same problem on windows 7 64bit 7zip.
After doing some research I found the following points:
1) single/double quotes ' " does not work on windows - 7zip says incorrect wirdcard
2) excluding based on file/folder attributes is not possible - only option is either to exclude with wild cards or make an exclude list.
3) in -x option, file is denoted as < path>\< filename.ext> and a folder as < path>\< folder>/ (with a slash at the end)
4) format 1: with ! mark (pattern directly with command) you can give something like:
a) 7z a -xr!<path>\<folder to exclude>/ archive.7z <zip folder>/
This excludes .svn folder in any path from zip folder recursively
b) 7z a -xr!*\.svn/ archive.7z <folder>/
5) format 2: with @ symbol you can give exclude list like this:
a) 7z a -xr@<7z exclude list file> <archive name>.7z <folder>/
where an exclude list file can have:
*\.svn/
*\output/
*\Document/
*\Measurements/
*.xlsx
*.bak
my favorite option is to use an exclude list
7z a -xr!*\node_modules/ archive.7z d:\Workspace\my-project
using the trailing slash for node_modules folder or not (your point 3) ) did not make a difference though. –
Holdfast this would work for ignoring hidden files ... 7z.exe a -xr!.git\ -xr!*~ ".zip"
.git
hidden folders , and it works! –
Sym I had a problem on Win64 and an exclude file. I couldn't get the .git
folder excluded. The simple ".git\" didn't work, neither any other usual patterns. In the end excluding "*git\" worked (note: no dot).
© 2022 - 2024 — McMap. All rights reserved.