What are Folder Actions?
Everyone’s workflow includes repetitive tasks that are performed in response to files being added to or removed from folders: perhaps you start a Time Machine backup when you save an important file, always open Transmission when a .torrent file is downloaded, regularly check shared folders for new files, repeatedly upload resources to a remote server, or simply add a line to a log file whenever you add or delete files. Wouldn’t it be convenient if these tasks were automatically taken care of for you?
Folder Actions, one of OS X’s powerful automation and scripting features, can tell the system to monitor a folder and automatically execute an Automator workflow, AppleScript, or shell script when items are added to or removed from the folder. The ability to automatically do virtually anything as files are added to or removed from folders can be a huge time saver in any workflow.
As an introduction to Folder Actions (and, if you’re not already familiar with it, Automator), we’ll create a simple action that automatically prompts us to give our screenshots descriptive names as we take them.
On older Macs, startup can take a long time. One of the main causes of this is apps that launch at startup. These apps can take the form of menu-bar apps like Dropbox and Growl, or full-fledged apps that you always use and have set to open at login.
Chances are, you don’t need to use all of those apps immediately after you log in. Today I’m going to share a way to use AppleScript to stagger the launch of these apps. That way, the apps you need first can start launching before the apps that you need later. Apps open faster when there is less ‘competition’ from others opening at the same time, so you’ll be able to use the apps you want first sooner after you log in.
On my older MacBook, the time from showing my desktop to loading all my startup items was shortened from 42 seconds to 35 seconds.
Welcome back to AppleScripting! To see what we’ve done so far, take a look at the AppleScript category. We’re jumping ahead a bit, but you should be able to catch on fine. As always, if you have questions you can ask in the comments and on Ask Different.
Today we’ll be making a workspace-based app launcher. Once we’re done, you’ll be able to choose a workspace (e.g., “Programming”) from a list and automatically have AppleScript launch the apps you use in that workspace.
The scirpt will use many different parts of AppleScript; including loops, lists of records, and
To begin, create a new script in AppleScript editor. See the Introduction to AppleScript post if you need a reminder of how to do that.
Let’s get right into the code.