English

macOS: zip files without .DS_Store and __MACOSX

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 my_compressed_file.zip path/to/folder -x "*.DS_Store" -x "__MACOSX"

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

Hope it helps. Cya!

bgasparotto

View Comments

Recent Posts

Python function decorator

This guide will show you how to create a Python function decorator with a few…

2 years ago

Got permission denied while trying to connect to the Docker daemon socket

This guide will show you how to fix the error Got permission denied while trying…

2 years ago

Python virtual environment on Intellij IDEA

This guide will show you how to create a Python virtual environment on Intellij IDEA…

3 years ago

Find and kill processes on Linux and Mac by port number

This tutorial will quickly show you how to to find and kill processes on Linux,…

3 years ago

Python: Relocation R_X86_64_PC32 against symbol can not be used when making a shared object Error

This guide shows a possible solution for Python error Relocation R_X86_64_PC32 against symbol can not…

3 years ago

Kubernetes useful commands

I condensed below a cheat sheet of Kubernetes useful commands. I will keep updating this…

3 years ago