Mar 04, '11 07:30:00AM • Contributed by: prijker
I use my faithful Butler to run Finder's usual operations, like copying, moving, and deleting files, making both my mouse and trackpad completely useless devices. As a keyboard-only user, I also wanted to add some other Finder operations, such as file compression.
Here is a small AppleScript, to be run from Butler (or any other script-launcher utility), that will compress the current Finder selection into a .zip archive, with the same name and within the same location. You can launch this script from Butler, triggering it with an abbreviation or a keyboard hotkey.
My script is based on this hint and turns it into a Finder-selection script.
I didn't test any compression levels, as my only point was to be able to compress a Finder selection directly, using ditto.
Also, it was tested in 10.6.5 only.
tell application "Finder"
activate
set theItems to the selection as alias
set theItemsprops to properties of theItems
set itemPath to POSIX path of theItems
set destFold0 to (container of theItems) as alias
set destFold to POSIX path of destFold0
set itemName to name of theItems
do shell script ("ditto -c -k --sequesterRsrc --keepParent " & itemPath & " " & destFold & "'" & itemName & "'" & ".zip")
end tell
[crarko adds: You should also be able to make this into an Automator Service, and assign a keyboard shortcut to produce the same effect.]
