a question about folder actions...

I am writting a folder action. In the middle of this action I have to create a new directory on the same directory that the action is attached. So, after creating that directory the action will be triggered again and will stop running… suppose the following diagram…

folder action is attached to folder desktop

folder action code…

line 1
line 2
line 3…
bla bla
tell application “Finder” to make new file at desktop with properties {name:"myFolder}
line 100
line 101
bla bla

as soon as the folder is created on tell application line, script will stop running and instead of running line 100, will begin line 1 again, cause it was triggered by the creation of the directory on the desktop…

How to solve that?

Is there any way to disable the trigger until the script is finished?


have the script ignor folders?

Hi, macos_boy.

It’s obviously preferable for a Folder Action script not to create anything in the folder that triggers it. It’s doubly preferable not to attach actions to the Desktop!

However, it’s possible to prevent multiple firings by switching off Folder Actions temporarily while a file or folder is created:

blah blah
tell application "System Events" to set folder actions enabled to false
tell application "Finder" to make new folder at ....
tell application "System Events" to set folder actions enabled to true