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:
- In Automator select new application (Launch Finder > Applications > Automator)
- Add a Shell script to your newly created app
- Pass input as arguments
- Now in the area provided input the following bash script:
zip -r "$filename".zip "$filename" -x */.*
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