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

I want to use launchd to kick off a script to backup changed files. It looks like it should work for what I want to do, but I don't know how to pass to my script that launchd starts, the path of the updated file. So if I'm watching directory foo and file bar.txt is changed, how do I get my launchd.plist or the script it runs to get the value of bar.txt?

share|improve this question
up vote 1 down vote accepted

I haven't found any way to do it with launchd. Could you just use rsync or something? Or check the modification dates in the script, by for example using find if it's a shell script:

find /some/path -mindepth 1 -maxdepth 1 -mtime -20s

Folder actions do get pathnames as an argument, but they are only run when files are added to a folder and not when files are modified. You can create a folder action by using the folder action template in Automator, or by saving a script like the one below in ~/Library/Workflows/Applications/Folder Actions/ and then enabling the script from Folder Actions Setup.

on adding folder items to this_folder after receiving these_items
    say POSIX path of item 1 of these_items
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.