How to exclude a directory when zipping files

cygwin;zip

I'm trying to exclude a certain directory when building an archive using zip. Here's what I have tried:

$ zip home.zip -y -r HOME -x '/AppData' -x '/AppData*' -x '/AppData/*' -x 'AppData' -x 'AppData*' -x 'AppData/*'

Produces:

  adding: HOME/ (stored 0%)
  adding: HOME/AppData/ (stored 0%)
  adding: HOME/AppData/a (deflated 39%)
  adding: HOME/AppData/LocalLow/ (stored 0%)
  adding: HOME/AppData/LocalLow/Sun/ (stored 0%)
  adding: HOME/AppData/LocalLow/Sun/Java/ (stored 0%)
  adding: HOME/AppData/LocalLow/Sun/Java/a (deflated 39%)
  adding: HOME/AppData/LocalLow/Sun/Java/Deployment/ (stored 0%)
  adding: HOME/AppData/LocalLow/Sun/Java/Deployment/a (deflated 39%)

My directory tree looks like:

./HOME
./HOME/AppData
./HOME/AppData/a
./HOME/AppData/LocalLow
./HOME/AppData/LocalLow/Sun
./HOME/AppData/LocalLow/Sun/Java
./HOME/AppData/LocalLow/Sun/Java/a
./HOME/AppData/LocalLow/Sun/Java/Deployment
./HOME/AppData/LocalLow/Sun/Java/Deployment/a

So it seems to be ignoring my -x options.

What is the correct syntax for the -x option?

Found this post but as you can see above, it didn't solve my problem.

I am using Info-ZIP 3.0 on Cygwin 1.7.35 on Windows 7.

Best Answer

Just do

-x */AppData/*
# or
--exclude */AppData/*

Don't forget to add the first slash, because otherwise it also matches any paths that has "AppData" in it, not just specifically the path that starts with "AppData".

Related Question