don't run script if script is already running.

I’m triggering an applescript externally from my midi controller. I only want the script file to be triggered if it is not running.
so Is there a way to check if the script file is already running first?
This way I can only repeat the script when the script has fully completed it’s run.

Hi Maybe something like this:

property should_run : true

on run
	if should_run then
		set should_run to false
		-- do something
		repeat 10 times
			beep 1
			delay 1
		end repeat
		set should_run to true
	end if
end run

it won’t stop the second script from running, but just the part where you want to do something. Not sure what you’re whole script is about.


One thing that I was wondering about is how many folders do you have?

If it’s running as an application (has it’s own proces name) then you could use pgrep

do shell script "pgrep '<processname>' || '/path/to/app/contents/resources/MacOS/<processname>' &>dev/null &"