How to: Turn terminal’s recursive zip into an application

This blog posts is one of the several guest blog posts to MikeSel.info. Posted by one of my readers Thomas Hazlett, Thomas managed to stumble across a neat way to turn OS X’s terminal recursive zip function into an application, using nothing but the built in OS X Automator application.

The below example essentially allows you to drop a folder onto a pre-compiled automator application and get back it’s zipped output. With one major benefit, it skips the inclusion of all of the OS X indexing files (.DS_Store etc) normally included when you use the context menu to create your archive.

The below example was built for OS X Mountain Lion, but can easily be adjusted for OS X Lion and earlier installs..

To achieve this snazzy little tweak:

  1. In Automator select new application (Launch Finder > Applications > Automator)
  2. Add a Shell script to your newly created app
  3. Pass input as arguments
  4. Now in the area provided input the following bash script:

Essentially, input file/folder including path is $1. Some simple string operations to extract necessary data. Quotes are required to allow for spaces in the pathname.

zip -r (recursive) OUTPUT INPUT -x (exclude) [ I have chosen to exclude all . (dot) files but this could be changed to a list of specific files, i.e. for ds_store files, replace */.* with */.DS_Store ]

Now – to make the icon slightly less dull, all you need to do is load an image into your clipboard by using cmd and C, and then using Cmd and I to display the applications attributes, then using Cmd and V to set the icon from your clipboard image.

Thomas Hazlett is from and still lives in Belfast, N. Ireland. He is currently studying with the Open University towards his BSc in Computing and IT however has decided to take a year out to work on his own projects; start a blog; and spend more time doing home renovations. You can find more about him at www.hazlett.info

Mike Hudson

Mike Hudson is a Infrastructure Analyst living and working in Kingston Upon Hull. With extensive experience in Microsoft and Apple technologies, ranging from desktop OS’s to Server OS’s and hardware. By day working as part of an infrastructure team, and by night ridding the world of IT issues through blog posts..

%d bloggers like this: