How to Exclude Files When Zip in macOS

When using macOS zip tool from the command, you may want to exclude certain files by name or extensions. I often need to do this when automating extension bundles for a release. Here is the command I use to exclude __MACOSX and DS_Store files that macOS creates.

zip -r deploy.zip . -x ".\*" -x "\_\_MACOSX" -x "*DS_Store"

The -x flag exlcudes files that match the pattern. Here is a list of other options for the zip command line tool.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.