Skip to Content

AppleScript: Exploring the power of Folder Actions, part II

In the last AppleScript post, I mentioned some of the useful ways to create Folder Actions, and showed you how to use one of the built-in scripts to perform a pretty useful action. In this AppleScript post, we'll dive into the built-in scripts in more detail, and I will tell you how each of them works.

Once you create a new folder action (as we did in the last tutorial), you will have a pop-up dialog asking if you would like to attach an Apple-created script. There should be around 13 preinstalled on your Mac. Now let's go through each of them, and see what they will do when attached:

Add-new item alert.scpt - This included script, which we covered in the last post, allows you to get a pop-up dialog upon dropping files in the attached folder. So, if you were to drop file x into the folder, a dialog would display a message that file x was just dropped in there. This script is great for networked folders, as you get a dialog when someone drops something in there.

Close-close sub-folders.scpt - This script will, when a file is dropped in the attached folder, close all opened Finder windows associated with that folder and subfolders. So, if you have that folder opened, or another subfolder within that folder, when you drop a file into it the script will close those opened Finder windows. You can use this script to tidy up your screen.

Convert-PostScript to PDF.scpt - If you have a PostScript file type (i.e. eps or ps files), then you can enable this folder action. When you drop a PostScript file on it there will be two folders created, one called "Original" and the other called "PDF." This folder action will take those PS files and turn them into PDFs for your instant viewing pleasure. You can use it in your workflow to easily convert from PS to PDF.

Read on to learn about even more built-in folder action scripts.


Image-Add Icon.scpt - The script will create an icon for each image file, based on the contents of the document.

Image-Duplicate as JPEG, PNG, TIFF.scpt - In each of the three scripts, when you drop an image file on the folder, the action will duplicate the file as either a JPEG, PNG, or TIFF. If you drop either of the output file types on the folder, the images will not be duplicated. This could be attached to a folder that you could use to easily convert between image file types.

Image-Flip Horizontal/Vertical.scpt - With these two scripts, you can easily flip an image horizontally or vertically when an image file is dropped on the folder.

Image-Rotate Left/Right.scpt - These two scripts allow you to flip a dropped image file either left or right.

Image-Info to Command.scpt - This script adds information about the image to the Spotlight comments field. Once this information is entered, you can view the comments by choosing "Get Info" on the image in the Finder (or in conjunction with the next script).

Image-Show comments in dialog.scpt - This script will pop-up a dialog box that contains the information contained in the attached folder's Spotlight Comments field. This script can be used along with the Info to Command script that was mentioned directly above.

And there you have it, a description of the 13 included folder action scripts. In the next AppleScript post, I'll walk you through creating your own custom folder action scripts.

Categories

Features AppleScript

In the last AppleScript post, I mentioned some of the useful ways to create Folder Actions, and showed you how to use one of the built-in...
 

Add a Comment

*0 / 3000 Character Maximum

8 Comments

Filter by:
Doug

Any chance one of the original options (immediate printing) is possible? I would love to be able to drop photos, documents, and other stuff immediately and seamlessly without opening up the program used to create it. This may be impossible, but it would be nice...

February 23 2009 at 5:14 PM Report abuse rate up rate down Reply
1 reply to Doug's comment
Frederico

Why not just use Printer proxies?

Do this: Go to ~Library/Printers or /Library/Printers and make an alias of your desired printer.

If it is a PostScript printer, most documents can be instantly printed without opening the parent program by simply dropping them on the printer (or printer alias) icon. This can also be done by dropping them on the printer icon in the Dock.

Your results will vary if the printer only emulates, or is not a genuine PostScript printer.

AppleScript's Standard Suite and System Events libraries each also contain print commands; these will often allow printing of common doc types (PDF, txt, rtf, etc.) without opening the parent app.

HTH

Rico

February 23 2009 at 7:50 PM Report abuse rate up rate down Reply
Gp

I gotta agree with Jan. I use this feature every day and it hasn't worked right since the beginning. Maybe my problem is using Automator to process the files, but it never seems to work. I thought it would be easy

1. Filter the files with a particular extension
2. Open the files in a particular application
3. Delete the files once they are opened

I have yet to make this simple workflow working reliably since leopard was released with FS events.

February 23 2009 at 4:54 PM Report abuse rate up rate down Reply
stirwin

Great tutorial. I have a fax folder, where all newly arrived faxes via my Apple modem reside. I tried this to see if it would pop up a message to say a new fax had arrived, but it doesn't work. Is there a tweak that will do this?

February 23 2009 at 2:50 PM Report abuse rate up rate down Reply
Jan Rychter

Unfortunately, I have had only poor experiences with Folder Actions. First, I believe they are prone to race conditions. When files are created slowly, say by copying over a network, your actions will start before the entire file is actually there. Second, I kept having problems where my script would only get, say 3 out of 10 files dropped into a directory. The other 7 would never get processed.

As a result, I decided it is a gimmick which Apple does not pay attention to, and stopped using it...

I would love to be proven wrong -- the day somebody shows me a script that I can attach as a folder action that will reliably process multiple movie files copied over a network into that directory will be a very happy day for me.

February 23 2009 at 1:37 PM Report abuse rate up rate down Reply
1 reply to Jan Rychter's comment
VanillaSpice

There are (rather clunky) workarounds to that problem. See - http://dougscripts.com/itunes/itinfo/folderaction01.php and http://www.yvs.eu.com/documentation/scripts.html

February 23 2009 at 8:35 PM Report abuse rate up rate down Reply
Kill_Brian_Kraus

Can't wait for the next article--I love Applescript!

February 23 2009 at 10:40 AM Report abuse rate up rate down Reply
Brendan

I was experimenting with Folder Actions after reading the first article in this series and mine only seem to activate when I open the folder, instead of activating with something new is placed in it. Any ideas on how to get the actions to activate even if the folder is closed?

February 23 2009 at 9:17 AM Report abuse rate up rate down Reply
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.