Here’s something for both new and experienced Mac users — Part One of a short tutorial on how AppleScript can streamline your work, make you more productive, and save you time!
What Exactly is AppleScript?
AppleScript is an English-like language used to write programs that control applications on your computer. The “English-like” part is important — it means that you don’t need to have a computer science degree to use it.
Simply put, it’s programming for regular people who want to get things done faster.
The programs that you write in AppleScript are called “scripts” (you saw that coming, right?). Much like the script for a movie, an AppleScript is really just a list of instructions for your computer to follow. It’s kind of like saying to your Mac, “Okay — when I say this, you need to do X, Y, and Z.” Honestly, that’s all that scripting means… giving your Mac a To-Do list.
Best of all, it’s free! Apple generously includes several tools that you’ll need to get started with automating tasks on your Mac — including the AppleScript Editor, which is used to write and save new AppleScripts for your computer to follow.
What is AppleScript Good For?
If you’ve ever known the soul-sucking drudgery of having to perform the same tasks over-and-over again on your computer, then AppleScript is for you! AppleScript automates repetitive tasks for you. So, instead of wasting time doing everything by hand, your computer does it for you…
(This is, after all, what they are supposed to do in the first place. 😀 )
Need to change the names of 100 files? You can either spend the next hour clicking and typing yourself into carpal-tunnel-induced dementia1 — or spend 2 minutes to write a script, click a button, and it’s done!
Most programs on the Mac have at least some level of support for AppleScript and, if you look around Veritrope.com, you’ll see AppleScripts that I’ve written to work with (and to connect together) many popular Mac applications. There are literally thousands of AppleScripts available to automate your system (most of them free!).
And, if by some chance you can’t find a script that someone else has written to automate a particular task, it really is easy enough to write one for yourself.
How do I learn AppleScript?
People often write me asking “How did you learn AppleScript?”
The simple answer is that I started reading AppleScripts written by people who knew what they were doing. The more that I read, the more I understood what was possible — and also some of the things you needed to make a working script.
In other words — Before I could really speak AppleScript, I started to learn how to **THINK** AppleScript. It’s really not any different than if you were dropped into a place where you didn’t know the language. You’d probably understand what the people around you were getting at — long before you learned enough of the language to make yourself understood.
How To Learn The Language
The quasi-official macosxautomation.com site is probably the best place to get started. It has lots of introductory tutorials and code examples for the beginning AppleScripter — but also some great introductions to other utilities that really set the Mac apart (like Automator and Services).
People like Ben Waldie (a guru of AppleScript and Mac Automation) — as well as any number of people who post on the MacScripter forum — also really helped me get going. I was truly inspired by their projects… and also by the community that they maintained to help new people like me get started.
As I started to really get more into it, I also found some great books about AppleScript (Especially Sal Soghoian’s “AppleScript 1-2-3”)
Learning How To Think
All of the resources that I just mentioned are the places to learn the actual ins-and-outs of programming in AppleScript… Honestly, you really can’t do much better than all of these great, talented teachers! Read what they have to say — and they’ll whip your scripting vocabulary and programming grammar into shape before you know it!
What I’d like to do here is a little different: I want to try and teach you how to think in AppleScript so that, while you’re learning from these great resources, you’ll have an existing framework for understanding what they’re trying to teach you. That way when it comes time to write your own scripts, you’ll hopefully have a stronger sense of what your looking for and, what’s more, the types of scripts you’ll need to put together to make it all work.
In Part Two of this series, we’re going to start to build our first sample script: An AppleScript that will save your emails as text files!
- This is not a real condition…I hope! [↩]