Whats with __MACOSX in Zip files?

More and more people are using Mac’s for development these days. As an example, a lot of the core developers from some of the leading web frameworks use Mac as their primary development platform. Several plugin and theme authors for WordPress also develop on Mac. While this is a good thing, there is one particular side effect of this development that annoys me beyond relief.

It seems that the easiest way to archive something on Mac is to right click on your directory of choice in Finder and select “Archive as…”. This creates a Zip file, which then the developer can distribute to users. The problem is that Apple, like many other software giants, tends to twist and bend the user’s will and interpret what the user wants to mean something else. In this case, the natural thing for the OS to do is pack up that directory, and ONLY that directory in a Zip file. But no sir, how can that be? How can Apple “transparently” embed some metadata in the Zip file so that if some other Mac user opens it in Finder, he/she can benefit from this metadata.

Apple does this by creating another folder suspiciously named ”%%__MACOSX%%” at the root of your Zip archive. Here’s an example (its the Cutline theme):

0 02-02-07 12:37 Cutline 1.1/
12292 01-31-07 17:16 Cutline 1.1/.DS_Store
0 02-02-07 12:38 __MACOSX/
0 02-02-07 12:38 __MACOSX/Cutline 1.1/
82 01-31-07 17:16 __MACOSX/Cutline 1.1/._.DS_Store
82 01-31-07 00:12 __MACOSX/Cutline 1.1/._ie6.css
238 01-30-07 23:59 Cutline 1.1/ie7.css
82 01-30-07 23:59 __MACOSX/Cutline 1.1/._ie7.css
0 09-13-06 17:30 Cutline 1.1/images/
12292 09-13-06 17:30 Cutline 1.1/images/.DS_Store
0 02-02-07 12:38 __MACOSX/Cutline 1.1/images/
82 09-13-06 17:30 __MACOSX/Cutline 1.1/images/._.DS_Store
65705 09-11-06 15:55 Cutline 1.1/images/header_1.jpg
34365 09-11-06 15:55 __MACOSX/Cutline 1.1/images/._header_1.jpg
62867 09-11-06 15:59 Cutline 1.1/images/header_2.jpg
33224 09-11-06 15:59 __MACOSX/Cutline 1.1/images/._header_2.jpg
82708 09-11-06 16:01 Cutline 1.1/images/header_3.jpg
34855 09-11-06 16:01 __MACOSX/Cutline 1.1/images/._header_3.jpg
59780 09-11-06 16:03 Cutline 1.1/images/header_4.jpg
33555 09-11-06 16:03 __MACOSX/Cutline 1.1/images/._header_4.jpg

This folder contains, among other things, thumbnails for images in the original archive. Now, this kind of unwanted, undesirable outcomes just really really annoy me. But I’ll try to keep my cool, and present a systematic analysis of not only why what Mac OSX does is wrong, but also stupid and unnecessary:

  • No surprises: As a user, I don’t like surprises, specially of the bad kind. If I request to archive a directory into a Zip file, thats exactly what I want. If I later unarchive that zip file, I should get my original directory back. Nothing more, nothing less. Any kind of unintended behavior is BAD.
  • We are not stupid: If I wanted you to stick in an extra folder named ”%%__MACOSX%%” in my archive, I’d let you know. Your users are a smart group, don’t insult them like this.
  • I hate clutter: In my WordPress themes directory, I unzip Cutline. If each theme starts creating its own ”%%__MACOSX%%” folder, then my themes directory would soon get cluttered with needless garbage.
  • It breaks things: If MacOSX did something harmless, like embed some metadata (like Zip file creator) into the Zip file itself, I might have been OK. But creating an entire tree structure in the archive just breaks things, in ways more than one. As an example, if like Cutline, each WordPress theme started creating ”%%__MACOSX%%” folders in the root of the archive, then later if I install another theme, I’ll get lots of errors and file name collissions because the new theme will also try to extract in the ”%%__MACOSX%%” folder. Not only this, some programs (like Gallery and WordPress) have the ability to load plugins/images directly from Zip files. As a result, I’ll end up with unwanted images, themes and plugins in my setup. Not only this, it might actually just break your installation. Since you did not create the ”%%__MACOSX%%” folder yourself, you don’t know what is in it, and it might not always obey the expecations of the software.
  • Security: Again, you did not explicitly create that folder. What if someone creates a virus, that just modifies the default zip program on Mac to sneak in malicious payload via the ”%%__MACOSX%%” folders in any new Zip archives you create? Apart from the security risk, its a time sink. Why should I go around cleaning up mess that I did not create? Software is supposed to make my life easier, not harder.
  • Redundant: From the looks of it, it seems that all of the data inside the ”%%__MACOSX%%” folder is created from the original directory. No external information is used/needed. If thats the case, why oh why would anyone EVER need this stupid new folder? If some metadata is needed, it can always be reconstructed from the original on demand. This seems downright stupid to me.

Would someone, anyone, please explain Apple’s intent and motivation behind this “feature”? What are the benefits (if any)?

58 comments

  1. Alex McCol

    hey dude, wat shit u wrote? i AM SMART AND UNDERSTAND TAT IT’S BAD and all wat i waana ‘now is – CAN i delete this folder after extracting and tat it won’t cause any damages to my files!

  2. Alex McCol

    Alex You are a muppet. If YOU SHOUT AT PEOPLE they are unlikely to help you.

    Diwaker – I agree, it does seem very stupid to be doing this. I wonder why they actually do it though.

  3. pirco

    i am just trying to find a solution … a software… what will NOT create those “hidden” files…

  4. zip

    I’m not positive on this but I do believe that the __MACOSX directory is created on purpose because older OS X applications actually use the resource fork. Not including this would cause said programs to break. It also has something to do with the HFS filesystem that it uses. I also don’t think there is a way to intelligently guess if something is using the resource fork, so they include it in the archives.

    So you can do 1 of 2 things:
    1) Buy a Mac – from the sounds of it you could use one.
    2) find . -name “__MACOSX” -exec rm -rf {} \;

    • Newb

      Thanks for the command, it worked like a charm. I could also remove the pesky “.DS_Store” files who somehow sneaked into the Zip.

    • HarlanSanders

      Why would he want to buy a Mac if he doesn’t like this behavior…

      #2 is the correct way to get rid of it. But it still doesn’t address the issue of the fact that it’s there and is nonstandard.

  5. John Russell

    Calm down and stop yelling. That superfluous folder you speak of is nothing but the resource fork of the .zip archive. Nothing to get worked up about.
    Also, the plural of Mac is Macs, not Mac’s. Learn your basic punctuation.

  6. Diwaker Gupta

    *@john*: Thanks for correcting my punctuation. Meanwhile, I don’t see any reason why I should suffer for a retarted way of doing things. It is _not_ “nothing but a …” as I have already explained in my post.

  7. Steve

    It gets more confusing when the Mac user then sends that file to a Windows user. Can I even use this Mac zip file?

  8. Sundev

    We were having this issue with one of the macs at my office. Since the directory structure of the zip file is traversed, this is causing some problems, but for some reason when I right click in Leopard to zip, my mac isn’t creating that file. It might be because I have stuff it installed, but I’m not sure.

  9. Diwaker Gupta

    *@brian*: thanks for the pointer. Though I’m a bit surprised (and disappointed) that they want to charge a fee for such a trivial software. In any modern programming language you could probably write a Zip archiver yourself in a few lines that doesn’t create those stupid files.

  10. Skeeve

    If you don’t want that stuff in you zip file, don’t create an Archive! If you archive, OS X puts everything in there it needs to restore the original content.

    If you want a ZIP file, create one! Use the terminal:
    zip -r cutline.zip ‘Cutline 1.1′

  11. VII

    Many thanks for the info…I feel that the Macs will soon go the way of Microsoft and start becoming more and more retarded and caring less and less about the end user, as they are becoming increasingly popular at an exponential rate. It’s sad but it’s a very human reaction to being presented with an advantage…since Vista is like the equivalent of computational Herpes, people are running in droves to Apple; but instead of just maintaining themselves as a company that puts the end user first, they will take advantage of the situation. Just like with the I-Pods…In actuality, they do what Microsoft does, only much better. In a sneakier, “spider-ensnaring-flies” kinda way…and it’s SO easy too. I hope that they realize that they need Microsoft to be #1 though, just like BugerKing needs McDonald’s to be #1.

  12. Diwaker Gupta

    @VII: for the sake of everyone involved, lets hope that doesn’t happen! I haven’t owned a Mac yet, but I am seriously contemplating buying a Mac Book Pro for my next laptop :) But you make an interesting point. I wonder how the Apple fanboy/fanatics would feel if Apple did indeed become #1 in the market. Would they still feel as cool?

  13. VII

    @ Diwaker Gupta : It’s the same with everything else that’s popular, after awhile everything that becomes mainstream becomes the new subject of hatred, not always just because of the simple fact that it’s now mainstream, but oftentimes because those that are accepted into the mainstream simply don’t know how to act when it comes to the increased power they have over they’re customers. It’s terrible that things are that way EVERYWHERE. We really need to go back to the days when corporations (and governments >_>) used to fear their fickle customers and aim to please them by any means necessary. Soon they’ll be talking about how, “back-in-the-day” Macs used to be for purists…

  14. Ergolad

    Hey how about the ATT00004.htm files and ATT00007.txt files that are created when sending mail from MAIL.APP to Outlook. Would like to prevent these from happening too. Suggestions?

  15. Ergolad

    Hey how about the ATT00004.htm files and ATT00007.txt files that are created when sending mail from MAIL.APP to Outlook? Would like to prevent these from happening too. Suggestions?

  16. jwa

    “If I request to archive a directory into a Zip file, thats exactly what I want. If I later unarchive that zip file, I should get my original directory back.” which is exactly why the Mac embeds the resource forks in the __MACOSX directory. Otherwise you would not get back exactly what you Archived; there would be data-loss of those attributes. These can include: file-type, creator, custom icon and others.

    I agree that when you unzip one of these on a non-mac (or with a non-resource-fork-aware unzip utility) you get cruft, which is easily dealt with via a “rm -r __MACOSX” command or using “uznip foo.zip -x ‘__MACOSX/*’ ” to unpack it.

    It is no different that the .DS_STORE files that creep into mac zips, or the tumbs.db that creep into windows zips when there are images in the directory.

    your points 2, 3, and 4 all fall prey to the fact that this is needed data for “get[ing] my original directory back”. I find point 5 flawed in that a malware capable of that could be putting copies of it self anywhere in your zip file: in .foo directories, replacing other files, etc There is no added security risk. Point 6 is incorrect because attributes like creator, customicon, and filetype metadata can NOT be recreated on demand from the file in any case where they were specified as non-default.

  17. Reza Jelveh

    i use the following for zip and mail bound to apple-shift-z(the original is from macosxhints forum i think with a little bugfix):
    nothing keeps you from using terminal though. or one of the various other freeware packing tools available. this resource fork is the reason why you see pictures instead of folders for certain zip archives onces theyre extracted. as for the collisions… nothing a little bit of force can’t fix ;p

    property theMonthList : {mJanuary:1, mFebruary:2, mMarch:3, mApril:¬
    4, mMay:5, mJune:6, mJuly:7, mAugust:8, mSeptember:¬
    9, mOctober:10, mNovember:1, mDecember:12}

    set temp to “lmr”
    –set theFold to choose folder with prompt “Bitte Zielordner auswählen:”

    set fileName to (temp & “-” & gib_Zeitstempel(current date))

    on gib_Zeitstempel(theDate)
    return ((((day of theDate) as string) & “-” & (Get_Obj(my theMonthList, “m” & month of theDate)) as string) & “-” & (year of theDate) as string) & “-” & ((time of theDate) as string)
    end gib_Zeitstempel

    on Get_Obj(theObj, theProp)
    tell (run script “me
    on f(theObj)
    return theObj’s ” & theProp & ”
    end f”) to return f(theObj)
    end Get_Obj

    tell application “Finder”
    set theItem to selection as alias
    set itemPath to quoted form of POSIX path of theItem
    set ZuErsetzenText to name of theItem
    set theFolder to POSIX path of (container of theItem as alias)

    set zipFile to theFolder & fileName & “.zip”
    do shell script “zip -r -j ” & (quoted form of zipFile) & ” ” & itemPath
    – delay 1 — this may be needed (and adjusted) for larger folders?
    try — We don’t need to say anything if there are no .DS_Store files
    do shell script “zip -d ” & (quoted form of zipFile) & ” ‘*.DS_Store’”
    end try
    end tell

    tell application “Mail”
    set theMessage to make outgoing message
    tell theMessage
    set zipFile to (zipFile as POSIX file) as alias
    make new attachment with properties {file name:zipFile} at after the last paragraph
    end tell
    set visible of theMessage to true
    end tell

  18. Kevin Mitchell

    Presuming your unzip executable is in /usr/bin, and that you’re using the bash shell, you can fix this problem once and for all by putting the following in your ~/.bashrc

    unzip() {
    /usr/bin/unzip “$@” -x ‘__MACOSX/*’
    }

  19. thesenewkicks

    Doesn’t make sense to me. They should have just used the UNIX filesystem standard of a ‘.’ prefix in the directory name. Created a “.macosx” and kept the metadata in there. Also, I wonder what happens if the user creates a directory called “__MACOSX”? Escape characters? Or will it just disappear into the void of meta-data nothingness?

    • Rico


      They should have just used the UNIX filesystem standard of a ‘.’ prefix in the directory name. Created a “.macosx” and kept the metadata in there.

      Since most Windows users and a lot of Mac users tend to “hide’ dot files from themselves, this could result in the buildup of junk over time. Better to hang it out there and let the user decide if they want it or not…

  20. Justin Bur

    The zip shell command on Macs creates standard zip files, just like everyone else’s.

    The Compress (formerly Archive) command in the Mac OS X Finder creates zip-compatible archives but does not use the zip command (nor will unzip interpret the __MACOSX directory correctly). The “ditto” command with the “-k” (zip-compatible) option can create these archives and extract correctly from them, and the ditto man page gives an example of mimicking the Finder’s Compress command from the shell.

    The information contained in __MACOSX contains all manner of things that cannot be expressed in simple file systems and simple archive formats. There are old-style Mac resources in there sometimes (though not so much these days, as they are obsolete). Mostly, the extra information is extended attributes and metadata. Mac users would not be happy if it were lost.

    Those who want just the simple bytestream and nothing else should avoid the Finder’s compress command and instead use one of the solutions that other posters have proposed (or just run zip from the shell).

  21. Vladimir

    Thank you Diwaker for the information. I work with PC only and your explanation is very useful for me. Though your post was sent in February, 2007 it is still actual. I just downloaded the last 2.3 version of WP-Forum WordPress plugin from its home page. It contains the __MACOSX/ folder you wrote above. WordPress plugin and theme developers must be aware about such problem and build clean installation packages, free of any unnecessary staff.

  22. Pingback: Is new installed Wordpress plugin package clean? | ShinePHP.com
  23. Mael

    Interesting article – I was wondering why the hell zip files from my friend on a Mac has this annoying folder in. I thought it may have been a ridiculous part of the Mac file system. I’m glad it’s not.

    However, wow… Talk about bias! “More and more people are using Mac’s for development these days … Several plugin and theme authors for WordPress also develop on Mac. While this is a good thing …” It’s good? Why? I don’t think I’ve read anything so funny before! That statement is ironic when this article itself is about a superfluous subject.

  24. Rick

    While I feel your pain, Mac users also have complaints about archives created on Windows boxes… the “thumbs.db” file(s).

    Instead of having one directory in the root (__MACOSX) that can be easily deleted, the thumbs.db files are in every directory of the extracted data. These of course can be deleted using a find command, but it is a real pain in the rear! I would rather delete one folder than have to find hundreds of files!

    I use both OS X and Windows, so I am used to dealing with the oddities of both… remember that there is two sides to everything, you’ve only experience your side of it because you are on Windows. Come to the other side and experience from a Mac perspective and you may start saying “the way Micrsoft does it is not only wrong, but stupid and unnecessary!” ;-o)

  25. Sebastian

    There is a simple solution for this issue:

    Install a real operating system. I love Apple hardware, but their software is privative and sucks!

    Install fucking Ubuntu, and stop using that retarded OS that is OSX.

  26. c0de

    LoL i just asked me this Question several times, and you gave me an Answer… Thats really one of the most Stupid things i know about Apple now… What a fucking Shit! (Espessialy what you say about WordPress, is really true and fucking bad for everybody!) … Stupid System for Stupid users without Brain…

  27. c0de

    LoL i just asked me this Question several times, and you gave me an Answer… Thats really one of the most Stupid things i know about Apple now… What a fucking Shit! (Espessialy what you say about WordPress, is really true and fucking bad for everybody!) … Stupid System for Stupid users without Brain…

    And sure windows creates ONE fucking File, but bye Windows everybody know its shit…

  28. Jam

    I believe it’s imperialist propaganda. A user of another operating system sees the folder and thinks, “wow. Macs can create zip files too!”, thus causing them to switch over.

  29. Brain

    I’ve got a powerhouse of a PC running at 3.9Ghz – stable – and for 1/3 the cost of the comparable MAC, and it doesn’t create any unwanted affects what-so-ever. Not only do I not care about little punctuation and spelling mistakes in comments unlike some of these pre-madonna posters, but I wouldn’t dream of giving that snooty, stuck-up, pretentious Steve Jobs any of my hard-earned pennies. Seriously, folks.

  30. Jason Hogg

    “The zip shell command on Macs creates standard zip files, just like everyone else’s.”

    This presumes that the brain dead mac users even know how to use a shell. Not one that I surveyed here in our office even knew what the hell the shell is.

    How about a free zip program or command that just makes a zip, no mess no fuss, with no extra ._ files or folders? Simple solution. Funny how on my PC I can just right click and zip anything and it is readable by all OS.

    • rlhamil

      Please don’t assume what Mac users are like just because you haven’t found any in your office
      with a clue.

      I’ve been using Unix (the real thing, not the cute
      but amateur wannabe Linux) since v7 on the
      PDP-11. I don’t think I’ve ever logged into
      anything with a GUI without starting a
      terminal ASAP – even my iPhone has a local
      terminal window (jailbreaks are wonderful).

      All metadata is stupid if you don’t want it, and
      ranges from useful to indispensable (by existing
      apps) if you do.

      About half of any given group of people is average
      or below. If there are enough people that never
      used anything but the graphical console on (for
      example) Ubuntu, probably a fair number of them
      won’t know what a command line is either.

      OS X mostly does its part by having a way
      (at the command line) to produce portable
      archives either with metadata or without
      (although at the present state of affairs, doing
      anything useful with metadata is quite nonportable). It falls short by not including
      a GUI way of producing portable archives
      either with or without nonportable metadata.

      That leaves it to the users to exercise their brains
      a bit and either discover the command line or
      at least realize they’re doing something that
      might not be helpful and track down one of
      the ways to extend the GUI to create
      unpolluted archives.

      I think the real problem isn’t one OS vs another.
      The real problem is that anything that starts
      out with a shallow learning curve lets people
      pick up enough to be more or less useful
      very quickly, but seldom offers much incentive
      for them to discover more advanced functionality.
      Most people are lazy; they don’t read labels or
      instruction manuals or anything they don’t
      have to. (Put a MOTD on a timesharing system
      way back when, days in advance of an outage,
      and notice that it doesn’t reduce the number
      of phone calls when the system goes down;
      this even with a population of users that log in
      just about every day.)

      The other problem is when people have only used
      one OS, or one mail client, or whatever; esp.
      when one person is communicating to many.
      When one person is communicating to one other
      person, it’s maybe ok if they share the burden. But
      when one person is communicating to many, they
      really ought to work harder to produce an efficient communication rather than waste a few minutes of many people’s time with something that overlooks
      differences. (Common example is emailing MS Word docs created with a recent version of Word
      when many in your audience still use an older
      version that can’t open the new format.)

      Sadly I’d expect this to only get worse. Blogs,
      texting, IM, Twitter, and other social networking
      sites encourage young users to routinely blurt
      out TMI in incoherent fashion. Unless counteracted
      by teaching writing and oral communication for
      precision and clarity from an early age on, we’ll
      end up with a generation that doesn’t know
      discreet from discrete not only because they can’t
      spell, but because discreet (and concise) are
      concepts completely without foundation for them.

  31. HZC

    Here’s a simple solution. Download ZipCleaner from http://homepage.mac.com/roger_jolly/software/ and move the app to your Applications folder. Open the app; it will appear in your Dock. Right-click on the icon in the dock and select the option to keep in dock; close the app.

    Now, after you create your zip archive, just drag it to the icon. It will ask you to confirm and then replace your zip with a “clean” zip that you can use on Windows.

    • Simon

      Brilliant! ZipCleaner solved my problem for this issue, recommend it for anybody else in the above thread experiencing the same problem.

  32. Dan Chokola

    Disclaimer: I am not a Mac user and actually have a burning hatred for Macs and their fanbase. I came across this webpage trying to figure out just what is in those __MACOSX directories.

    There are a couple solutions here. https://discussions.apple.com/thread/1640973?start=0&tstart=0

    IMHO, VII hit the nail on the head when he said that Mac is going mainstream. It invalidates the “We are not stupid” point as well. As Mac tries to sell itself to the average stupid user more and more, expect crap like this. Your best bet is to just use the command line, or roll your own script, which were made for the smart user.

    The “Redundant” point is a memory/CPU time tradeoff. Rather than have a user recreate this metadata from files, which takes CPU time, it’s stored in the zip file and available immediately to the user after it’s unzipped. There is a legitimate reason for this, then. That said, I agree the metadata could probably be stuffed into the archive somehow that gets ignored by normal zip programs and picked up by the Mac zip program.

    • Zana

      As someone who recently had to use some Macs for work (after years of coding/scripting/Windows domain management) I have to agree with the author that often the Mac OS behavior is idiotic and NOT “more user friendly.”

      To me, needing to issue a TERMINAL COMMAND is HELLISHLY more complex than it needs to be. It is not “simple” by any stretch of the imagination. You COULD use Powershell/CMD to do crap like this but the point is that in Windows basic stuff like this is EASY to do and follows LOGICAL, PREDICTABLE steps.

      Obviously, as someone who has debugged hundreds of thousands of lines of assembly in IDA Pro, it’s not “hard” for me to use the terminal to show hidden files or create an archive, but I really don’t care about whether it’s “hard” for me. The point is that it is outrageously harder IN COMPARISON to Windows to achieve the same thing (create a simple Zip file without added thumbnails/metadata). Using a command line to accomplish things is virtually NEVER easier unless you (a) have a photographic memory (b) there is no other way. Unix/Linux/Ubuntu did not become more popular/usable by ELIMINATING graphical options.

      Saying “oh here’s the solution, just download a third party application to correct the problem” is basically agreeing that Mac has failed to do anything better than the competition, since that is basically how Windows/nix work. The whole point of Mac is ALLEGEDLY that is does things better/more simply out of the box, but in fact it requires terminal commands to make basic changes…

  33. Khurrum

    I was expecting that last point: It can be reconstructed on the fly. “Why are you putting it inside a compressed file which is compressed so people can save space?” – first.

  34. Marc O. Chouinard

    It just another annoying Apple Brainwashing technique. To most technical people that haven’t being corrupted, this is annoying as hell… But to the rest, it publicity… An constant reminder they arn’t running Mac…

  35. Pingback: General Kext question NOOB
  36. Pingback: Fiddler's Green Free Models - PaperModelers.com
  37. Damien [Bit Innovate]

    And 7 years and a month after you told them what the situation is and to cut it out, they continue doing this crap. I just spent good money on a plugin and am currently experiencing a good dose of nerd rage. When it’s free it’s annoying, but when I get a bonus piece of OSX doody with something I paid for, it makes me go on the internet.

Leave a Reply