(1) Drop the code urging you to "Select folder(s) to remove folder actions from "
Build a loop treating every folder listed in FolderActionNames
(2) Drop the code urging you to "Select script(s) to remove from "
Build a loop trying to disable each actions referenced in the list FAScripts
tell application "System Events" to set FolderActionNames to name of every folder action
repeat with EachFolder in FolderActionNames
set FolderActionName to contents of EachFolder
tell application "System Events" to set FAScripts to name of every script of folder action FolderActionName
repeat with EachScript in FAScripts
set ScriptName to contents of EachScript
tell application "System Events" to delete script ScriptName of folder action FolderActionName
end repeat -- EachScript
tell application "System Events" to delete folder action FolderActionName
end repeat -- EachFolder
If you simply want to delete all your folder actions, this will do it:
tell application "System Events" to delete folder actions
I you want to delete only actions whose folders no longer exist, you have to check their ‘paths’. The situation’s a bit strange (in Snow Leopard, at least) in that an action’s ‘path’ value is actually an alias. Furthermore, if the folder to which the alias refers is zapped, the value’s still an alias, but the decompiled form of the specifier has a POSIX path instead of an HFS one! eg.alias “/Users/aardvark/Desktop/Wibble/”. This coerces to text as a POSIX path, so the following works:
tell application "System Events"
set currentActions to folder actions
repeat with thisAction in currentActions
if (((path of thisAction) as text) contains "/") then delete thisAction
end repeat
end tell
However, a POSIX path in an alias specifier is an aberration and it would be safer to use an error technique:
tell application "System Events"
set currentActions to folder actions
repeat with thisAction in currentActions
try
(path of thisAction) as text as alias
on error number -43
delete thisAction
end try
end repeat
end tell