The discovery, acceptance & management of life's gaps

The Birth of AppleScrunix

Thursday 31 March 2011 - Filed under automation + gaps + Technology

On March 24, 2001 Apple introduced it’s ‘Unix’ based version of Mac OS, Mac OS X. Steve Jobs said, “Mac OS X is the most important software from Apple since the original Macintosh operating system in 1984 that revolutionized the entire industry.” See Mac OS X Hits Stores This Weekend. The following 10 years saw Apple morph from has-been to has-it-all. Check out Adam Rosen’s fun piece chronicling the evolution of OS X, Welcome to Mac OS X: An Illustrated Introduction [10th Anniversary], on Cult of Mac.

While reinventing the Mac, Mac OS X also revitalized my favorite scripting language, AppleScript. In addition to providing “control of scriptable applications and of many parts of the Mac OS,” OS X gave AppleScript access to the power of Unix, and introduced me to what I like to call AppleScrunix.

AppleScript has long offered Mac power users a way to do what they love to do better and faster. Sal Saghoian, AppleScript Product Manager at Apple, and de facto king of AppleScript, rightly states in his book, AppleScript 1-2-3, that AppleScript is the “power to make the computer do what you want and need it to do for you.”

The mashup of Applescript and Unix, AppleScrunix, brings two automation powerhouses together, creating (arguably) the most powerful automation platform on the planet. A simple example can be illustrated by solving a common problem in scripting, that of creating a date/time string for the unique naming of files.

In order to create a date/time string to append to a file name consisting of Year, Month, Day, Hours (military time), Minutes and Seconds, such as 20110331155523

…straight AppleScript might look like this:

set cd to (current date)

set text item delimiters to ""

set dateTime to year of cd & text items -2 thru -1 of ("0" & (month of cd as integer)) & text items -2 thru -1 of ("0" & (day of cd)) & text items -2 thru -1 of ("0" & (hours of cd)) & text items -2 thru -1 of ("0" & (minutes of cd)) & text items -2 thru -1 of ("0" & (seconds of cd)) as string

…with AppleScrunix you can do this:

set dateTime to do shell script "date +%Y%m%d%H%M%S"

We will delve deeper into AppleScrunix in future posts.

2011-03-31  »  Russ Leseberg

Share your thoughts

Re: The Birth of AppleScrunix

Tags you can use (optional):
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>