Applescripting is a gift from Apple. It is a great scripting language that can tie savvy applications together to automate mundane processes to make your life easier. It can work minor miracles. Unfortunately, its greatest asset is also its greatest weakness. The English-like language makes it easy to learn but also frustrating . Sometimes, it is difficult to see how applescripting would make life easier. The balance of time spent scripting and debugging versus the time taken to do something by hand is unique to each task. FCS steps in with a few applescripts to automate some tasks that most people may find useful. Even if moving email messages to your iPod doesn't save your business lots of money or make it quicker to read email, perhaps it'll make it more convenient for you. These scripts are semi-useful scripts to show some of the possibilities of using applescript and how you can fit them into your life. You are encouraged to open the scripts in Script Editor and take a look at the code.
Mail to iPod
This applescript fetches your email and copies all of your new messages to the notes folder of your iPod. You can then take your unread emails with you. This script has been updated twice by others with many thanks.
- Download v1.0 | View source
- Download v1.1 by Oskar Lissheim-Boethius. Added: Puts a user-defined number of your most recent emails into the notes folder on your ipod, and cleaned up the division of emails in to 4k messages.
- Download v1.2 by Ben Klocek. Fixed a problem, where the script started at the oldest email, not the newest. Corrected this, so now the script grabs the unread messages in your inbox. Removed user defined number capability. No way I could find to grab the most RECENT n emails.
iTunes to HTML
This one generates an HTML table that contains the name, album, artist, and genre information on the songs in your playlist. You can copy that table into an HTML file to show the world what you listen to.
I was asked to update the iTunes to HTML to export some categories and not others. I rewrote the script to let the user choose what information is exported to the HTML file.
Convert Applescript to HTML
This Applescript takes the frontmost Script Editor document and converts it into an HTML script. To use, simply toss this script into ~/Library/Scripts/Script Editor and select this script from the scripts menu in OS X. Your current script will be parsed and exported as an HTML document. On large scripts, however, it could take some time to work its magic. This script was used to create the documents behind all the "View source" links on this page!
Fellow scriptor Jan was kind enough to update and improve this script. It now works much faster and supports Unicode-flavored text. In addition, he also created a script droplet that will convert any scripts dropped onto it.
Download script | Download droplet | View script source
Post to Weblog
Blogging is increasingly popular activity. Luckily, most blogging packages and content management systems let you send information using a standard called XML-RPC. Apple built XML-RPC into Applescript, enabling savvy users to get (and send) information to remote servers. This script sends an XML-RPC message to any blogging system that uses the Blogger API. It comes prepared for use with Considera but can be altered to use any applescriptable application.
Clear Safari caches
An article on MacDevCenter talked about using applescript as an alternative to Safari's "Empty Cache" feature. It unfortunately would've been better off as a shell script than an applescript. I rewrote the script to be more applescript-like.
Change Safari 3's page load progress indicator
Based on a tip found on Flickr, I created a small applescript application that changes Safari 3's page load progress indicator into a circular pie indicator. The application will also revert Safari to the default settings if re-run.
Save Terminal directories
If you work in the Terminal, you've likely been in a situation where you wanted to quit and come back later but didn't want to have to reopen all the windows and change back the directories. Sure, you could save the windows but then you have to find the save file and reopen it. This script saves everything to a preferences file and makes it just as simple to restore. This script demonstrates working with the Terminal as well as working with property list files.
[MarsEdit] Add category to weblog
I use MarsEdit to do my blogging. It’s a great little application but I’ve run into one big problem. For some reason, it won’t fetch categories from my WordPress blogs. I solved this problem by writing an applescript that edits the property list file in which MarsEdit stores weblog information.
Expand text snippets
TextMate has a great feature where text snippets can be easily expanded into standard boilerplate text. For programmers, this often means taking something like arr and having it expanding into NSMutableArray *array = [NSMutableArray array];. This feature alone can save a lot of reptitive programming. The Expand Snippets script approximates that feature for Xcode and TextWrangler. When paired with Fast Scripts, this script can save Xcoders from a lot of repetitive programming. Some assembly required (details in included ReadMe).
Can image spam
Image-based spam has a tendency to slip through Mail's junk filter. Mail can't see that this image is spam and the spammers make it more difficult for Mail by adding text below the image that isn't spam-like. Unfortunately, Mail's filtering rules don't provide options for gracefully handling this spam. Mail can, however, run an applescript as a rule action. The Can Image Spam applescript runs a few simple tests to help determine whether incoming mail is this image spam.
Away
If you use Skype, Adium, iChat, and/or Twitter, you may have a headache keeping your status messages updated. The Away script synchronizes these applications and Twitter for you. This makes it easy to keep everyone informed of what you're doing. As an added bonus, Away makes use of FCSApplescriptAdditions, a small application I wrote to provide useful additions to applescript.
Replace Dock Images
With the release of OS X 10.5 (Leopard), many people have been creating Dock replacement images. They usually distribute these in folders with installation instructions. This applescript will install folders of images for you, making it easy to try out new Dock styles. Better still, it will automatically create a backup of your current Dock so that you can always restore it.
TextWrangler scripts
These applescripts were created before TextWrangler had a BBEdit-style Unix filters feature. In essence, they allowed TW to make us of Unix filters through the magic of applescript. Since TW now has a dedicated filter feature, these scripts are practically useless but are still provided only for historical purposes. These scripts demonstrate using two perl scripts from John Gruber and a python script from Aaron Swartz.
Script Editor plugins
Code Snippets
Code Snippets is a Script Editor plugin that adds an extra menu item to Script Editor's Windows menu. The Snippet window stores small bits of code that you're likely to reused when writing scripts. The source is included.
Download Code Snippets installer
Recent blog posts for applescripters
- A bug that’s never fixed…
- Hell froze over
- Call Cocoa from Applescript
- [AS] Applescript and the command line
- [AS] Execute bundled scripts correctly
