Clear all Folder Actions?

I’m currently use a script to create folders and with these it puts a Folder Action.

When I delete the folders all the rules still show in the folder actions.

How can I run a script to delete all the rules? (Short of manually going in and selecting all to delete)

Thanks

Matt

Would be a good idea to look at :

Macintosh HD:Library:Scripts:Folder Actions:Remove Folder Actions.scpt

which is delivered with the operating system.

Yvan KOENIG (VALLAURIS, France) mercredi 22 février 2012 15:45:52

Very useful never looked that far only the Folder Action Scripts folder.

I tried using it but you need to select the folder, I need to select all folders in the desktop.

But also you still have to select which ones you want to delete.

How could I streamline this?

(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

Yvan KOENIG (VALLAURIS, France) mercredi 22 février 2012 17:26:02

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

Hello Nigel

Same behavior under Lion :slight_smile:

Yvan KOENIG (VALLAURIS, France) jeudi 23 février 2012 15:26:11