MacOS – Compress without .DS_Store and __MACOSX

archivefoldersmacos

When I compress a folder or file by right click menu of Mac OS X, the archived file contains .DS_Store and __MACOSX folders. Because I share the archived file online for download, Windows users mistakenly trying to search the file in __MACOSX folder.

I need to have a cleaner archive option. I do not want to include .DS_Store and __MACOSX folder, but only the file or folder into the archive file.

All I found is CleanArchiver but it is GUI application. It really takes time and I have lots of files to compress. I am looking for a solution by context menu if possible.

Is there any solution that you can recommend for clean compressing?

Best Answer

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.