Skip to content

macOS: zip files without .DS_Store and __MACOSX

Last Updated on 16/11/2020

linux shell

Whenever you have to zip and share files, you probably don’t want to include the .DS_Store file and __MACOSX folder in the zip file.

What are these files for?

The .DS_Store (Desktop Service Store) is a hidden file containing attributes of its enclosing folder, such as the icon size display. The  __MACOSX folder is created during the zip process and contains metadata about the compressed files.

How to exclude .DS_Store and __MACOSX from the zip file?

The zip command has a -x parameter that excludes a file or folder of a certain pattern from the resulting zip file. Additionally, the -x parameter can be declared multiple times in order to accomplish multiple exclusions.

For instance, to exclude both .DS_Store file and __MACOSX folder, simply run:

zip -r path/to/folder -x "*.DS_Store" -x "__MACOSX"

to compress all the contents of path/to/folder directory to the file.

Hope it helps. Cya!


1 thought on “macOS: zip files without .DS_Store and __MACOSX”

Leave a Reply

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