Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac zip compress without __MACOSX folder?

Tags:

macos

zip

People also ask

Can I delete __ MACOSX folder?

Can I Delete The __MACOSX folder? On Windows, absolutely – it's no good to you at all. Just useless tat taking space up. On Mac, you can't see it anyway.

What is __ MACOSX folder in zip file?

What is the __MACOSX folder? The __MACOSX folder is created when a Mac user creates and archive (also called a zip file) using the Mac. If the Mac user sends the zip file to another Mac user, the folder will not appear - this is a hidden folder. Many files on the Mac have two parts: a data fork, and a resource fork.


Can be fixed after the fact by zip -d filename.zip __MACOSX/\*


When I had this problem I've done it from command line:

zip file.zip uncompressed

EDIT, after many downvotes: I was using this option for some time ago and I don't know where I learnt it, so I can't give you a better explanation. Chris Johnson's answer is correct, but I won't delete mine. As one comment says, it's more accurate to what OP is asking, as it compress without those files, instead of removing them from a compressed file. I find it easier to remember, too.


Inside the folder you want to be compressed, in terminal:

zip -r -X Archive.zip *

Where -X means: Exclude those invisible Mac resource files such as “_MACOSX” or “._Filename” and .ds store files

source

Note: Will only work for the folder and subsequent folder tree you are in and has to have the * wildcard.


This command did it for me:

zip -r Target.zip Source -x "*.DS_Store"

Target.zip is the zip file to create. Source is the source file/folder to zip up. And the -x parameter specifies the file/folder to exclude. If the above doesn't work for whatever reason, try this instead:

zip -r Target.zip Source -x "*.DS_Store" -x "__MACOSX"