How to exclude a directory from zip archive using info-zip (included with Mac OS X)

Alec Jacobson

July 23, 2009

weblog/

I had a hard time finding the right command to do this online. There were a lot of red herrings (or at least different commands for different zip flavors). Here's how to zip all contents or a directory recursively except certain subdirectories.

If you want to zip up the files in dir/ and your directory tree looks like:
dir/
dir/include/
dir/exclude/

Then the command:

zip -r foo.zip dir -x /exclude/* 
Will recursively archive all files in dir/ and dir/include but not in dir/exclude into the zip archive foo.zip.