Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Programatically enable/disable folder action scripts System
A tidbit for people who like Folder Actions. The System Events app (a faceless background app that allows AppleScript to work with system functions) has a suite for working with folder actions which lets you add, remove, or enable/disable scripts on particular folders on the fly. For instance, say that you have a dropbox folder with an attached folder action to modify files when they are added or removed, but you want to be able to open the folder and add/remove files directly without the script being triggered.

Save the following two subroutines as a script, and attach it to the folder along with your other script (of course, change other script to the name of the other script that runs on the folder):
on opening folder thisFolder
  tell application "System Events"
    set enabled of (script "other script" of folder action thisFolder) to false
  end tell
end opening folder

on closing folder window for thisFolder
  tell application "System Events"
    set enabled of (script "other script" of folder action thisFolder) to true
  end tell
end closing folder window for
Opening the folder in the Finder will now disable the other folder action script until you close the folder window again.

[robg adds: I haven't tested this one.]
    •    
  • Currently 2.00 / 5
  You rated: 5 / 5 (9 votes cast)
 
[7,012 views]  

Programatically enable/disable folder action scripts | 3 comments | Create New Account
Click here to return to the 'Programatically enable/disable folder action scripts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Programatically enable/disable folder action scripts
Authored by: dilvish1984 on Sep 24, '09 11:52:07AM
I think when you said:
The System Preferences app has a suite for working with folder actions...
You meant to say:
The System Events app has a suite for working with folder actions...
And you might want to note that although this is an app technically, anyone unfamiliar with AppleScripting should not expect it to behave like an app in any sense they are familiar with (i.e. it resides in their CoreServices folder at the /System/Library path rather than in one of the Applications folders, and does nothing (apparent) when double-clicked...)

[ Reply to This | # ]
Programatically enable/disable folder action scripts
Authored by: tedw on Sep 24, '09 05:10:00PM

whoops, you're right - bummer typo that. I'll send a note to Rob and see if he can fix it.



[ Reply to This | # ]
Programatically enable/disable folder action scripts
Authored by: dilvish1984 on Sep 24, '09 11:59:40AM

Users of this hint should note that if you were to open the aforementioned folder in the Finder and forget to close it, the primary folder action would continue to be disabled (I suspect the same would also be true if the Finder crashed after opening the folder but before closing it...) These secondary behaviors might not be obvious at first glance.



[ Reply to This | # ]