Reduction
A script is a means of reduction: it combines multiple steps into a single operation. Instead of doing one thing, then another, then another, you do just one thing—run the script. I particularly like using AppleScript for reduction. Having worked out a series of steps to accomplish a task, I often realize that not only do I not want to have to go through them all again later, but also I fear I won’t even remember them again later! My AppleScript program remembers the steps for me.
Here’s an example. From time to time I have to reboot my computer into Mac OS 9. The drill is: open System Preferences, switch to the Startup Disk pane, click the Mac OS 9 System folder, hold the Option key, click Restart. Too much work! Too many steps, too much waiting, too much hunting for the right thing to click on, too much clicking. Here’s the script that does it for me:[1]
try
do shell script ¬
"bless -folder9 'Volumes/main/System Folder' -setOF" ¬
password "myPassword" with administrator privileges
tell application "System Events" to restart
end tryI’ve got that script saved as an applet, which is a little application written with AppleScript. To run the script in an applet, you just open the applet like any application. So this applet is sitting right on my desktop, where I can’t miss it. To restart into Mac OS 9, I just double-click it. Now that’s something I can remember.
Here’s another example. A journal for which I occasionally write articles requires me to submit those articles ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access