Create ZIP archives on a Mac without .DS_Store or .svn
I’ve been posting little zip archives of the latest scal on the site for awhile now using the nice “Create Archive” feature in OSX. Problem is, when you create a ZIP archive all of the happy Mac hidden directories come along for the ride. This includes .DS_Store. If the directory is under version control you also get .svn directories too.
After playing about with a variety of methods (and nifty tools), I settled on using the good old zip command’s exclude directive (-x) to skip the hidden directories.
The -x directive lets your specify files to skip while creating an archive. It can also take a file as an argument, in which you might store a lot of directory patterns.
Here’s how you do it:
zip -vr scal_0.2.zip * -x@exclude.lst
This will create an archive of all files in the current directory (with a recursive romp through sub directories) and skip any file that matches the patterns defined in the file exclude.lst. My exclude.lst looks like this:
*.svn*
*.DS_Store*
exclude.lst
I include exclude.lst because it is in the same directory as my files and I do not want it included in the archive. If you make a script out of this command, you can put the script filename in your exclude.lst file.
Enjoy!
adding: index.html (in=8314) (out=2136) (deflated 74%) adding: javascripts/ (in=0) (out=0) (stored 0%) adding: javascripts/effects.js (in=38685) (out=8904) (deflated 77%) adding: javascripts/prototype.js.. (in=124137) (out=28414) (deflated 77%) adding: javascripts/scal.js (in=13987) (out=3486) (deflated 75%) adding: javascripts/scalplanner.js (in=5440) (out=1416) (deflated 74%) adding: javascripts/unittest.js (in=20202) (out=5049) (deflated 75%) adding: planner_test.html (in=4472) (out=1486) (deflated 67%) adding: scal_unittest.html (in=4023) (out=1264) (deflated 69%) adding: scaltester.html (in=2710) (out=950) (deflated 65%) adding: scaltester_new.html (in=8312) (out=2130) (deflated 74%) adding: slick_test.html (in=1836) (out=808) (deflated 56%) adding: styles/ (in=0) (out=0) (stored 0%) adding: styles/images/ (in=0) (out=0) (stored 0%) adding: styles/images/blackback.jpg (in=699) (out=369) (deflated 47%) adding: styles/images/blueback.jpg (in=721) (out=541) (deflated 25%) adding: styles/images/blueline.jpg (in=1089) (out=975) (deflated 10%) adding: styles/images/bullet_red.gif (in=282) (out=208) (deflated 26%) adding: styles/images/close.gif (in=167) (out=167) (stored 0%) adding: styles/images/next.gif (in=875) (out=301) (deflated 66%) adding: styles/images/prev.gif (in=879) (out=305) (deflated 65%) adding: styles/scal.css (in=11114) (out=2600) (deflated 77%) adding: styles/scaltables.css (in=4052) (out=880) (deflated 78%) adding: styles/stylemain.css (in=914) (out=340) (deflated 63%) adding: styles/test.css (in=1291) (out=474) (deflated 63%) total bytes=254201, compressed=63203 -> 75% savings











YemuZip (from Yellow Mug) does it well for me.