Has anyone been successful at deploying folder actions through Casper? There appears to be some potential with an Applescript. I've gotten the following script to work for 10.6 up through 10.10 but the "attach action" command appears to have been deprecated in 10.11. It will enable folder actions on the specified folder in 10.11 but does not assign the folder action script.
tell application "System Events"
attach action to folder "path/to/folder" using "path/to/script"
end tell
My other thought was to edit the “com.apple.FolderActionsDispatcher.plist” located in the user’s preferences folder. This is storing the data that assigns the folder actions and scripts. However, the XML node storing the data I would need to change appears to be encrypted. Initially, my thought was that I could use the “defaults write” command to edit this file and use some variables to accommodate for all the different accounts. Anyone know if there’s a way to edit this plist if it’s encrypted?
Best answer by gavin_pardoe
I have script for configuring folder actions. been a while since i last used it but it worked really well. you just need to change the path to the target folder and script you are applying to it.
tell application "System Events"
--Set Varibles and Create Aliasesset folder actions enabled totrueset userTrash to (path to trash folder) as string
set theScript to POSIX file "/Library/Scripts/Folder Action Scripts/touch.scpt"as alias
set targetScript to theScript as text
tell application "Finder"toset scriptName to name of alias targetScript
set targetFolder to the userTrash as text
end tell
set targetFolder to the result as text --Configure Target Folder
tell application "Finder"to ¬
set FAName to name of alias targetFolder
tell application "System Events"if folder action FAName existsthenelse
make new folder action ¬
atendof folder actions ¬
with properties {path:targetFolder} -- name:FAName,
endifend tell
tell application "System Events" --Congifure Script for Target Folder to Use
tell folder action FAName
make new script ¬
atendof scripts ¬
with properties {name:scriptName}
end tell
end tell
I think you're describing how you push out the folder action. I probably should have titled the post "Assigning or Attaching Folder Actions via Casper." The title is probably misleading. I've been able to push out the folder action. The part that I'm stuck on is assigning a specific folder action to a specific folder. Basically, via a script, mimic how you use the "Folder Actions Setup" app to do this.
Can you use a LaunchD? Or LaunchAgent for user based? Drop this in /Library/LaunchDaemons along with creating the folder and script to run as needed in the paths mentioned below.
<?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"><plistversion="1.0"><dict><key>Label</key><string>edu.school.mywatchertool</string><key>ProgramArguments</key><array><string>/usr/local/COMPANY/ScriptToRun.sh</string></array><key>WatchPaths</key><array><string>/usr/local/COMPANY/FolderToWatch/</string></array><key>OnDemand</key><true/></dict></plist>
I initially looked at creating a launch agent with watchpaths. One of the requirements for this is that the script is only triggered by files being added. By default watchpaths will trigger the script for adding and removing files. I could not figure out how to limit the script to only be triggered by adding files.
I have script for configuring folder actions. been a while since i last used it but it worked really well. you just need to change the path to the target folder and script you are applying to it.
tell application "System Events"
--Set Varibles and Create Aliasesset folder actions enabled totrueset userTrash to (path to trash folder) as string
set theScript to POSIX file "/Library/Scripts/Folder Action Scripts/touch.scpt"as alias
set targetScript to theScript as text
tell application "Finder"toset scriptName to name of alias targetScript
set targetFolder to the userTrash as text
end tell
set targetFolder to the result as text --Configure Target Folder
tell application "Finder"to ¬
set FAName to name of alias targetFolder
tell application "System Events"if folder action FAName existsthenelse
make new folder action ¬
atendof folder actions ¬
with properties {path:targetFolder} -- name:FAName,
endifend tell
tell application "System Events" --Congifure Script for Target Folder to Use
tell folder action FAName
make new script ¬
atendof scripts ¬
with properties {name:scriptName}
end tell
end tell
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.