You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Folder Actions not working

I'm trying out folder actions for the first time, and I cannot get an action to trigger.

I regularly use Automator, and I've saved a script as a Folder Action plug-in attached to a folder. I've tried this with several different scripts.

For example, I've got a script that just displays a message. It works fine if I save it as an app, so I save it as a Plug In>Folder Action. If I select, say, my documents folder, I right click>more>attach a folder action. I then select my script. If I open the Folder Actions Setup, my script is listed as attached to my documents folder. However, if I drop a file into the Documents folder, nothing happens.

Am I correct in thinking that the script should run when a file is dropped into the folder (and if I'm wrong, how would you do this?), or have I missed something?

I'm using 2x 2,8GHz Quad-Core Intel Xeon Mac, OsX 10.5.6.

Cheers

Steve

Dual 2.5GHz G5 + 17 Powerbook 1.5GHz, Mac OS X (10.5.6), AJA IO & lots and lots of hard drives. . .

Posted on May 29, 2009 4:54 AM

Reply
9 replies

May 29, 2009 8:36 AM in response to Steve Archbold

You can't just save any-old script as a Folder Action script.

The script needs specific handlers that get called when specific actions occur - for example there's one handler that's called when new files are added to the folder, another one for when files are removed, and so on.

Attaching the script to the folder simply tells the OS to call the appropriate handler each time an action occurs. If your script doesn't have these handlers then no actions will be taken.

I've never tried creating aFolder Action from an Automator script, so I don't know the specific steps you're missing, but in regular AppleScript you need to add the handlers like:

on adding folder items to this_folder after receiving these_items
-- your code here to call when new files are added to the folder
-- this_folder is the folder you're attached to
-- these_items is a list of items added to the folder
end adding folder items

May 29, 2009 11:10 AM in response to Camelot

When saving an Automator workflow as a folder action plug-in, Automator saves the application in the ~/Library/Workflows/Applications/Folder Actions folder, then creates a wrapper AppleScript in the ~/Library/Scripts/Folder Action Scripts folder - something like:

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on adding folder items to this_folder after receiving added_items
tell application "Path:to:some:workflow.app"
open added_items
end tell
end adding folder items to
</pre>

The added items are just passed to the workflow, but depending on what the first action is, they can get mixed up. Some people have had more consistent luck with modifying the script to use the Finder to open the items with the application, instead of telling the application to open them. Also, since the system does it's usual "I expect the scripts to be where I think they should be" thing, the various items should be placed accordingly.

Jun 5, 2009 8:11 AM in response to Steve Archbold

In the Finder (Mac) Help, every user may read:

*+Running an automation when a folder is changed+*
+Folder actions let you run automations when a folder is modified. For example, you could run an AppleScript or an Automator workflow whenever something is added to a dropbox folder.+

+To use folder actions, you attach a folder action script or workflow to a folder. When the folder is opened, closed, or modified, the automation will be activated automatically.+

+Your script must include a handler for each folder action command used.+

+To make a folder action scripts available to all users of your computer, put them in the Folder Action Scripts folder located at:+

+Library/Scripts/Folder Action Scripts/+

+To make the scripts available only to the current user, put them in the home folder at:+

+~/Library/Scripts/Folder Action Scripts/+

*+To enable folder actions:+*
+1. Open Folder Actions Setup in the Applications/AppleScript folder.+
+2. Select Enable Folder Actions.+
+3. Click the ╋ button below the Folders with Actions list and choose the folder containing the folder actions.+
+4. Click the ╋ button below the Script list and select the desired scripts, then click Attach.+

My guess is that you missed one of the four steps.

Yvan KOENIG (from FRANCE vendredi 5 juin 2009 17:09:05)

Folder Actions not working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.