7zip: Exclude hidden directories

nQk picture nQk · Apr 20, 2015 · Viewed 9.1k times · Source

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

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

Answer

smls picture smls · Jan 9, 2016

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/