Apple - Compress without .DS_Store and __MACOSX

You can use zip command in Terminal to zip the files without the .DS_Store, __MACOSX and other .* files.

  1. Open Terminal (search for terminal in spotlight)
  2. Navigate to the folder you want to zip using the cd command
  3. Paste this:
    zip -r dir.zip . -x ".*" -x "__MACOSX"
    

Example

Let's say you have a folder on your desktop called Folder with stuff to zip.
Open terminal and write following commands:

  1. cd Desktop/Folder
    
  2. zip -r dir.zip . -x ".*" -x "__MACOSX"
    

Now you have a file called dir.zip without __MACOSX and .* files in the folder Folder on your desktop.


Just some extra information ...

My understanding is that __MACOSX is a subdirectory artificially created by the Mac GUI tools to hold meta data such as extended attributes that can't be normally saved in a zip file.

If you use the Mac GUI tools to unpack the zip file, then the tools will know what to do with __MACOSX and the directory won't actually get unpacked.

The problems happen when you send your .zip file to Windows or Linux users, or just use the general-purpose unzip program to unpack them. Those tools won't know that __MACOSX is special, and will just unpack it.

The simplest option is to use zip to pack up your zip file instead of the Mac built-in tool. zip won't create __MACOSX and your problem is solved. (You will lose the meta data in the process, but you probably didn't want it anyway.)

zip -r dir.zip .

If it's too late, and you already have a zip file with __MACOSX, you can still remove it with:

zip -d foo.zip __MACOSX .DS_Store

Finally, the accepted answer is the best because if for some reason __MACOSX actually does exist in your directory (e.g. because you previously used unzip to create it), the -x option will keep it from being packed up.


Try Keka. It comes with an option to exclude .DS_Store

enter image description here