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.


Thanks for reading. Make sure you follow me on Twitter to stay up to date on the progress of my side projects T.LYWeather Extension, and Link Shortener Extension. If you are interested in the tech I use daily, check out my uses page.  

Leave a Reply

Your email address will not be published.

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