AppleScript is so fun! That and Folder Actions are two of the reasons I love OS X.
So I recently had something come up where I had to make sure anything that was copied into one folder was immediately copied into another. Folder Actions made this simple.. now I haven’t added the functionality to make sure that anything that’s deleted from the master folder gets deleted in the Sync Folder but this script is good enough.
This Folder Action handler is triggered whenever items are added to the attached folder.
The script will copy new content into another folder
on adding folder items to this_folder after receiving added_items
set newPath to "/Users/loulou/Documents/Alt Sync/"
repeat with this_item in added_items
set fileName to name of (info for this_item)
set folderName to name of (info for this_folder)
set folderPOSIXpath to POSIX path of this_folder
do shell script "cp \"" & folderPOSIXpath & fileName & "\" \"" & newPath & fileName & "\""
#display dialog "Woo! Files copied."
end adding folder items to
I saved this code as an .scpt file in /Library/Scripts/Folder Action Scripts, attached it to a folder and I was set.