With this amazing OS X tool, a folder
isn't just a folder.
With the handy Folder Actions feature of OS
X, you can attach AppleScripts to specific folders, set to run whenever someone
adds files to the folders.
Automate tasks with Folder Actions
That means the scripts can trigger an alert
whenever new files are added to a specific folder, change the Finder labels
when you put files in a folder, and automatically unzip file archives. Here’s
how Folder Actions work:
Explore other built-in actions
OSX includes a handful of folder action
scripts in the /Library/Scripts/Folder Action Scripts folder.
For example, a number of scripts can act on
graphics - there are three that can convert image files to JPEG, PNG or TIFF
format. Let’s say you have a blog, and you want all your graphics to be in JPEG
format. Create a folder and attach the ‘image - Duplicate as JPEG.scpt’ script
to it. Every time you add an image file to that folder, the file immediately
gets converted.
All your Folder Actions, in this window, you can see all folders that have
Folder Actions attached to them, and which scripts they are set to run.
There’s also a nifty script you can use if
you often open a lot of folders within a specific folder. Closing all those
windows when you’ve finished with them can be annoying. Attach the ‘close
-close subfolders.scpt’ script to a folder, and any open subfolders get closed
when you close the top-level folder. This is useful for projects that require
you to access files in many subfolders.
Turn on folder actions globally
To use Folder Actions, you must first turn
this feature on globally. To do so, Control click (or right click) any folder
and choose Services > Folder Actions Setup.
(If you only have a few Services, you may
not have a Services menu and will instead see the Folder Actions Setup menu
item at the bottom of the contextual menu.) When you choose Folder Actions
Setup, a small window opens showing a list of AppleScripts. Select Enable
Folder Actions in the window, and then quit.
Get alerted to incoming files
If you share files with other people over a
network, your colleagues may deposit files in your Mac’s built-in Drop Box
folder. (Not to be confused with the cloud storage service Dropbox.) For how to
doing this, see the Apple support document support.apple.com/ kb/PH 10640.
But how do you know when a new file has
arrived? Add a Folder Action that displays a dialogue box whenever a new file
is added to your Drop Box.
To do this, first go to your Public folder.
You’ll find it inside your home folder -the one with the house icon. (Or, in
the Finder, select Go > Go To Folder and type —/Public). Control-click (or
right-click) the Drop Box folder that’s inside this folder, choose Folder
Actions Setup, click ‘add - new item alert.scpt’ and click Attach.
Let’s try this out. Place any file inside
this folder. Within a few seconds, you should see a dialogue box telling you
how many new items were added to the folder and asking if you would like to
view these items. Click Yes to open a window showing the files, or click No to
dismiss the dialogue box. You may not need to see the files right away, but now
you know that they have been added.
Another way to use this same script is with
your own Dropbox folder (part of the backup and file synchronization service at
www.dropbox.com). If you share files using Dropbox’s shared folders, you may
want to know when you receive new files.
Dropbox offers desktop
notifications-
floating alerts - but they fade away after a few seconds. Attach the same
script we used above to a shared Dropbox folder, and you’ll see an alert
whenever someone downloads new files to that folder
Drop Box alert. Once you attach the Folder Action to your Drop Box folder,
you'll see an alert like this every time someone puts something in the folder
Note that this only works when you add an
item to the folder itself, not when you add an item to one of its subfolders.
If you have a lot of subfolders in your shared folder, you'll need to apply the
same script to each of them to get alerts for all of the folders.
Turn off folder actions
If you ever want to turn off Folder Actions
for specific folders, you can access the Folder Actions Setup applet as
described above by Control-clicking (or right-clicking) any folder.
Dismiss the list of scripts, and you see a
list of folders for which you’ve set Folder Actions, along with which scripts
you’ve attached to them. Turn off any of these by unchecking them, or delete
any folder or script from the list by selecting it and clicking the minus-sign
(-) button.