Search This Blog

Thursday, January 6, 2011

How to get rid of __MACOSX metadata folder?

I was developing a NetBeans Zend Framework sample on Mac OSx and run into strange problem. Zipped directory contains metadata and unzipped folder has different structure as requested. I always got one more directory called __MACOSX after unpacking archive. You will not face this problem if you unpack using MAC archiving utility. But if you use this utility to pack and then you unpack under another OS or using another utility you most likely will get into troubles. Most problems are with automated unpacking because desired data are elsewhere then where you are looking for it.

As far as I understood what I googled up, metadata in archive are only stored when compressing a folder using Archiver utility. So, basically, when you create archive using "compress" from pop-up menu. They are created before, when you create a folder or a file. Metadata are stored in .DS_Store (Desktop Services Store) files.

So what to do about it?  Solution is actually simple, use command-line zip utility to zip your folder and you should be good. Don't forget to delete metadata files .DS_Store before.

rm -rf `find . -name .DS_Store`
zip -r archiveName.zip *


test how unzip behaves

mkdir unzip-test
unzip archiveName.zip -d unzip-test/


if there are no .DS_Stores file and/or __MACOSX directory then you should have archive without metadata and you should be good to go without worries :).

Links


Wikipedia on metadata
Mac OS X Resource Fork and Command Line Tips

No comments:

Post a Comment