How to Exclude Files from a Zip Archive

When zipping a folder using the command line in macOS, you may have noticed certain files are include such as DS_Store and __MACOSX are included. With a few command arguments, these files can be filtered out.

Exclude All Hidden Files

zip -r zipFolderName.zip pathToFolder -x "*.*"

Exclude .DS_Store and __MACOSX

zip -r zipFolderName.zip pathToFolder -x "*.DS_Store" "__MACOSX*"

Exclude all jpegs

zip -r zipFolderName.zip pathToFolder -x "*.jpegs"

Hopefully this helps you filter out unwanted files when zipping folders in macOS.

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.