Skip to main content
Solved

Enable Folder Action Scripts


Forum|alt.badge.img+5

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?

Best answer by thoule

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 original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+15
  • Contributor
  • 589 replies
  • Answer
  • January 26, 2017

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>

Forum|alt.badge.img+5
  • Author
  • Contributor
  • 18 replies
  • January 26, 2017

Does launchd recognize ~ ?


Forum|alt.badge.img+15
  • Contributor
  • 589 replies
  • January 26, 2017

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


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 18 replies
  • January 26, 2017

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings