AppleScript returns to Numbers, and other news for Jan. 29, 2014

Friday Favorite: Use AppleScript to delete files from a folder

AppleScript: the Script Editor

Before you can build your first AppleScript you need to know some basics: what a script-able application is and how to use the Script Editor.

Script-able ApplicationsBasically, script-able applications are applications in which the developer has included a set of "instructions" that the Script Editor understands and can use. Some apps are not script-able but most Apple apps are and, of course, Mac OS X itself is script-able.

The Script EditorThe Script Editor is a very simple application, but it allows you to do some very powerful things. The Script Editor is located in your Applications folder (Applications : AppleScript : Script Editor.app) by default. The editor has a simple interface with a prominent text entry area. It also has 5 buttons in the toolbar; for now we will only focus on the "Run" and "Stop" buttons. The run button will run the currently typed script, and the stop button will cancel a running script.

Running a ScriptLet's delve right into the Script Editor by running your first AppleScript! We will use the "tell" command. This command will allow you to tell a specific application to do something. For instance, if I wanted to open iTunes, I would type:

tell application "iTunes" to activate

You can substitute "iTunes" with any other application on your Mac, however, you must retain capitalization and spacing (if any) and include the quote marks around the application name. Now try typing the script and clicking the "Run" button at the top of the window. iTunes will open. Substitute activate with quit and run the script again. iTunes will now quit.

As you can see, AppleScript commands are very "English-like" in their structure. This is one reason that AppleScript is very easy to pick up as you go along.