Download the new Switched app for your iPhone

Skip to Content

Engadget for the iPhone: download the app now
AOL Tech

Filed under: Features, AppleScript

AppleScript: Exploring the power of Folder Actions, part I

Welcome to Part I of this mini AppleScript feature on creating useful folder actions. We'll have more posts on this topic coming up, but for now, let's introduce what a folder action is. Have you ever wanted to just drop a file into a folder and have something magically happen? Say, have a file printed, whisked to a remote site via FTP, or perhaps have an image be automatically flipped from horizontal to vertical? With Mac OS X's built-in folder actions, you can easily do this with a simple drag and drop.

Creating the folder
First, let's talk about how we can enable these "magical folders" that perform actions on files dropped within them. For this example, I'll show you how to make a folder on your desktop that, when a file gets dropped into it, will display a dialog letting your know that the file was placed there.
Start by creating a regular folder on the desktop; you can either right-click and select "New Folder," or select "New Folder" from the Finder's File menu.
After you name the folder, you can right-click on it and select More > Enable Folder Actions. Right-click again and select More > Configure Folder Actions. This will launch an AppleScript utility called Folder Actions Setup.app. You will now be able to add the appropriate actions to your newly created folder. On the left hand side of the window, you will see a plus (+), minus (-), and "Show Folder" button at the bottom. Pressing the plus (+) button will allow you to select an appropriate folder to add an action to -- select the folder on your desktop that you just created.

A menu will roll down asking you to specify an Apple-created script. We'll choose the "add - new item alert.scpt." This script will alert the user via a dialog when an item is placed in a specific folder. In the right hand side of the window you will now notice that the add script has been placed there. You can add multiple scripts to a folder action and they will be performed in consecutive order until the end of the list is reached. Once you have created the actions, you can close the window.

It's just a drag to the left.... activating the scripts
With the folder now set up to accept drag and drops, you can drag a file onto it. In a few seconds (depending on the copy time), you'll see a dialog popup on your screen alerting you that your file has just been copied into this folder. Pretty neat, huh?

I tend to use this same folder action for my Drop Box located in the public directory of my user account. Since this folder is available to the public via a LAN connection, I am alerted whenever someone drops a file into it. There are literally tons of uses for the add file folder action. Why not play around with it and let us know your favorite uses for it?

Coming up in Part II: we'll go through Apple's supplied folder scripts and identify which of them provide the maximum automation payoff.
jobs & resumes
iPhone / Android Developer

Bump Technologies, Inc. - Mountain View, CA (2 weeks ago)

See More Relevant Jobs ›

Reader Comments (Page 1 of 2)

Tip of the Day

Want to drag a file to another folder and copy it instead of moving it? Press the Option key when you drag that file and it'll be duplicated rather than moved entirely.

Follow us on Twitter!

TUAW [Cafepress] 

Featured Galleries

DNC Macs
Macworld 2008 Keynote
Macworld 2008 Build-up
Google Earth for iPhone
Podcaster
Storyist 2.0
AT&T Navigator Road Test
Bento for iPhone 1.0
Scrabble for iPhone
Tom Bihn Checkpoint Flyer Briefcase
Apple Vanity Plates
Apple booth Macworld 07
WorldVoice Radio
Quickoffice for iPhone 1.1.1
Daylite 3.9 Review
DiscPainter
Mariner Calc for iPhone
2009CupertinoBus
Crash Bandicoot Nitro Kart 3D
MLB.com At Bat 2009
Macworld Expo 2007 show floor

 

Our Writers

Victor Agreda, Jr.

Programming Manager, AOL Tech

RSS Feed

View more Writers

More Apple Analysis

AOL Radio TUAW on Stitcher