Enable Folder Action Scripts

msmith80
New Contributor III

I need to a way to attach a folder action script that I created to every users download folder. I know where the action scripts are stored, so I know how to get that into the right place. I just cant seem to figure out how to enable the action script through a deployment or using a terminal command.

Anyone have any ideas?

1 ACCEPTED SOLUTION

thoule
Valued Contributor II

I'd use a LaunchAgent and WatchFolder. Haven't tested this, but it should work....

But to test, put the file below in /Library/LaunchAgents/com.company.mygreatTool.plist and a script to to whatever in place of script.sh below. Every time the download folder gets touched, the script will run.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.company.mygreatTool</string>
<key>EnableGlobbing</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Library/path/to/script.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>~/Downloads/</string>
</array>
<key>OnDemand</key>
<true/>
</dict>
</plist>

View solution in original post

4 REPLIES 4

thoule
Valued Contributor II

I'd use a LaunchAgent and WatchFolder. Haven't tested this, but it should work....

But to test, put the file below in /Library/LaunchAgents/com.company.mygreatTool.plist and a script to to whatever in place of script.sh below. Every time the download folder gets touched, the script will run.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.company.mygreatTool</string>
<key>EnableGlobbing</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Library/path/to/script.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>~/Downloads/</string>
</array>
<key>OnDemand</key>
<true/>
</dict>
</plist>

msmith80
New Contributor III

Does launchd recognize ~ ?

thoule
Valued Contributor II

It does path expansion with the <key>EnableGlobbing</key> key.

msmith80
New Contributor III

Man I could kiss you right now! This just saved my life! Thanks buddy!