Folder Actions on Mac OSX Leopard?

has has.temp3 at
Thu Sep 25 13:39:54 CEST 2008

On 25 Sep, 00:30, Sean DiZazzo <half.ital... at> wrote:

> I always wondered about Folder Actions...  I just tested.  You can
> have applescript call python scripts via `do shell script`.  But it
> seemed a bit flakey.

Should work in theory. For which values of flakey? e.g. Is it a
technical problem with Folder Actions, AppleScript, 'do shell script,
and/or Python, or just your AppleScript code that needs some work
(e.g. there are some common gotchas with using 'do shell script' that
often trip up AppleScript newcomers).

FWIW, I would second the suggestion to look into FSEvents as a
possible alternative to Folder Actions. There's also kqueue which is
lower level but may have/have had Python bindings already written for

Alternatively, if the OP really wants to use FAs, there are a couple
of other options for that:

1. I've got a simple py2app-based application shell and an AppleScript
that automatically forwards FA events to that application - just
insert your Python code into the application shell and build it,
attach the AppleScript to some folders, and you're good to go. Email
me directly if you want a copy.

2. If you're brave, you could try using the PyOSA component on the
appscript website, which allows you to write OSA scripts in Python.
FAs will work with any kind of OSA script (.scpt files), not just
AppleScript ones. PyOSA is officially discontinued due to some
intractable limitations in its/CPython's design (specifically the
inability of an in-process Python interpreter to sandbox unrelated
scripts so that they can't interfere with each others' modules, file
handles, etc). However, it's reasonably functional and should be
usable for FAs with a little care.


Control AppleScriptable applications from Python, Ruby and ObjC:

More information about the Python-list mailing list