Running GrandPerspective while you sleep (iCal/AppleScript)

UPDATE: If you leave DVD Player or VLC Player in fullscreen-mode, this relatively simple AppleScript does not know what to do about itself, so you’ll wake up to a bunch of shortcut keys having been fed to random software :)  Also, this does not “freeze” keyboard/mouse input during the starting of GrandPerspective, so it’s best to set this to run while you are not awake!

GrandPerspective is one of my favorite tools. It’s a rather neat way to display big and small clusters representing folder contents. Now, that might not be the best way to describe the tool, but I do use it to quickly identify large files and make up my mind as to what to do with them.

However, GrandPerspective is fairly slow (at least on a super-full drive), and might take 3 or 4 minutes to run through my drive. What if it ran while I slept and was ready for me in the morning? Turns out there are multiple crontab tools for OSX, GUIs and everything. To be honest, I couldn’t make up my mind as to which one to install, or whether to start editing crontab directly. 

There is a simpler way. It is called iCal. Yep. Imagine how shocked I was to discover that, yes, iCal can be scheduled to run an AppleScript whenever you want, as often as you want.

First, let’s make something worth running every couple of days.

if application “GrandPerspective” = (not running) then
    tell application “GrandPerspective” to launch
end if
tell application “GrandPerspective” to activate

tell application “System Events”
    tell process “GrandPerspective” to keystroke “s” using command down
    tell process “GrandPerspective” to key code 36
end tell

It would be useful to stash the first few lines starting with if and ending with endif. You can recycle these lines to any application which you wish to launch if it isn’t open, or merely activate if it already is open. Always activate the application before sending it keystrokes and keycodes (key code 36 sends the Return/Enter key).

Save the script and launch iCal. Now, this one is so delightfully easy that some of you can already guess where to go and what to do, but here’s a picture anyway:

image

I’ve seen some brief articles describing the utilization of long iTunes playlists and iCal to schedule certain playlists to play during certain times. In the end, iCal saved me from going crontab on OSX. I’m sure I’ll eventually think up some other AppleScripts to run via iCal, but for now GrandPerspective seems to be the only one I can think of off the top of my head.

Here is one more image, this time of GrandPerspective having run to completion. 

image