Is there a folder action that tells you when a file has been modified?

I need to copy a file from a folder to another whenever it’s been modified. I thought it would be easy, there must be a Folder Action that can do it. Is there some kind of script that can do this automatically?

I think the easiest way to do this is with launchd

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

Save that file to ~/Library/LaunchAgents/com.tjluoma.copy-on-change.plist

Replace both instances of /path/to/original/file.ext with the actual path to the “original” file, and replace /path/to/where/you/want/it/copied/file.ext with the actual path where you want it copied to.

Note that the destination folder /path/to/where/you/want/it/copied/ must already exist for this to work, and obviously the “backup” copy will be overwritten on every change.

Once it is ready to go, enter this in

launchctl load ~/Library/LaunchAgents/com.tjluoma.copy-on-change.plist

Then change the file and see if it is copied.

If it is not, check /tmp/com.tjluoma.copy-on-change.log for any error messages.

Thanks so much, it worked like a champ:)

Great! Glad to help.