Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

7zip: Exclude hidden directories [closed]

Tags:

7zip

How do I exclude hidden directories when creating an archive using 7zip's command line version?

I tried -x!".*", but that didn't work.

like image 785
nQk Avatar asked Apr 20 '15 13:04

nQk


3 Answers

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/
like image 135
smls Avatar answered Dec 19 '22 02:12

smls


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

like image 35
Prasad Narasimha Avatar answered Dec 19 '22 00:12

Prasad Narasimha


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).

like image 25
Cornel Masson Avatar answered Dec 19 '22 00:12

Cornel Masson