Super User is a question and answer site for computer enthusiasts and power users. 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

Anyone know about a program for Mac OS that you can pass the name to an executable and a file to watch, so that it then runs the executable everytime the file being watched changed?

I have something like this in mind:

$ fwatch /Users/foo/doc.tex /Users/foo/ &
  fwatch running. Listening for changes in /Users/foo/doc.tex.
$ echo "This aint no LaTeX" > doc.tex
$ fwatch: Change in /Users/foo/doc.tex detected. Running /Users/foo/
share|improve this question
up vote 6 down vote accepted

You can set this up using launchd. Specifically, you need to use the watchpaths key in your launchd plist to look for changes in that file.

Exhaustive information available in this AFP548 article.

Although it appears it's no longer under development, Lingon is an application providing a GUI way to set up these launchd plist files.


Roughly, here's what you'd do using your sample paths above. Save a file named with the following contents to ~/Library/LaunchAgents

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Then you'd type launchctl load ~/Library/LaunchAgents/ in the terminal to load your file-watching daemon.

Above is untested, but that's the general idea.

share|improve this answer

You can do it in Automator. It is under Folder Option in the automator workflow I believe (not in front of a Mac). Then you just attach the script to the folder and it will fire every time a file is added/changed.

share|improve this answer
I can't quite follow. I'm new to Automator, but as far as I know you can't choose when to execute your script but only what to do when it is run. There's the folder actions in Mac OS that I could use also but I figured AppleScript only has the action "on adding folder items to" but nothing like "on changing folder items in". – Johannes Jul 15 '10 at 16:22
You are correct @Johannes. While there are folder actions for adding folder items, removing folder items, moving the folder window, closing the folder window, and opening the folder, there is no Folder Action for detecting changes to files. You can see this by opening the StandardAdditions.osax dictionary in Applescript Editor. – ghoppe Jul 15 '10 at 17:09

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.