Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder on my Computer, "Markdown Source" with a folder action applied to it through Automator. The folder action applies a shell script, and then writes output to a different folder, "Markdown Output" (no bonus points for guessing what the script might be).

The problem is that sometimes when I save a file to the "Markdown Source" the script runs, and creates the file in "Markdown Output", but sometimes it does not. This problem seems to happen most frequently if I re-add a file to the folder than has previously been in the folder but was subsequently moved elsewhere.

Does anyone know if there is a way to change how often Folder Actions look for new input, to manually force Folder Actions to run, or some other way to be sure that all the items in my Markdown Source directory get processed?

share|improve this question
The problem occurs with new files, not files you replace? Are you sure that the folder action doesn't get called at all, i.e. do you have secondary output that tells you it ran (but then e.g. aborted or failed)? Can you reproduce this with a minimal folder action that runs a problem that simply cannot fail to let you know it was started? Is the problem that you save multiple files in a very short time and only some of them are detected? – Daniel Beck Jan 5 '12 at 17:15
Edited. Newly added, but yes, the problem is most frequent with files that had been in the folder previously. – Daniel Jan 5 '12 at 17:40
This and the follow-up seem to suggest Folder Actions are just unreliable like that. You could always rewrite it into a program or service that runs the script on all files, no matter whether old or new (Markdown should be fast enough). – Daniel Beck Jan 5 '12 at 17:53
With the atomic writes used in most OS X applications (i.e. replacing the old file when saving instead of changing its contents), you could use a launchd job with the WatchPaths directive on the Markdown Source folder. Since the folder modification time is updated whenever a file is added, removed, or "atomically changed", you could launch your "rebuild all Markdown files" script I suggested earlier automatically with some reliability. This will not work if you use e.g. emacs or vi to edit the source files. – Daniel Beck Jan 5 '12 at 18:00
@DanielBeck if you post these two comments as an answer, I can accept. – Daniel Jan 22 '12 at 6:16
up vote 2 down vote accepted

In my and others' experience, Folder Actions are unreliable, especially with large numbers of changes. So the problem you're facing is not specific to your system, but a rather common one.

I suggest you rewrite your script into one that receives a folder as input, and performs the Markdown transformation on all files within. Have it trigger automatically whenever a file is written to by a launchd job, with the parent folder specified in the WatchPaths rule.

Since most programs on OS X perform atomic saves and thereby replace the previous file instead of simply modifying its contents, the folder will also be updated and the job will be triggered reliably.

Markdown transformation also shouldn't be too time consuming, and you can always ensure only to transform files using your script that were changed in the last X minutes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.