Applescript runs fast by itself but slowly inside of "if then else" block

I'm very new to writing my own Applescript. I've written this little code block that loops through finder windows to find if a certain folder is open and switch to that window. After that if it's not found it opens a new window at that location.

The script runs super fast by itself but when it is inside an "if" block that regex matches the front window title it takes about 2-3 seconds. Is it the condition that's holding things up? How do I check this?

I don't know why the AppleScript is running slower in the If/Else action, but I'm not sure you need it, either. KM's Open Folder action already brings the folder to the front if it's open, and opens the folder if it isn't, so based on what you've posted here, I think you might be able to replace that entire If/Else block with just the "Open %editsfolder%" action.

@gglick Oh my god you're quite right. Talk about making extra work for myself! Thanks mate

1 Like