Help needed! 🙂 Finder: if folder exists, open it. If not, create it

Hi folks! I'm having some trouble with a chain of actions that will later be part of a larger macro, and would appreciate this wonderful community's help!

What I'm looking to achieve at the moment:

While inside a Finder folder, search for the existence of a folder named TEST
If such a folder exists in this location - open it. If it does not exist, create one and then open it.

Thanks very much, I appreciate it!

Hi and welcome to the forum!

If I've understood you correctly, here's how I'd approach something like this, here set up with a prompt:

If folder exists at this Finder location- open it. If not- create it.kmmacros (4.4 KB)

Macro Image

Hi Alexander! First off, thanks so much, I really appreciate it. This works perfectly. However, I should've been more clear - The folder I'm looking to search for or create will always have the same name, so I don't actually need KBM to prompt me for the name. Rather, I want KBM to itself search for the folder name (which in my case will be _DLVR ), and then proceed as before - open it if it exists, create and open it if it doesn't.

Would appreciate if you could let me know how I can modify the macro you sent over to have it function this way. Also, is there a way for the _DLVR folder to open in the same finder window, rather than opening a new Finder window?

Thanks again, I really appreciate it!

1 Like

Then you could set it up something like this, setting the variables directly, instead of doing it trough the prompt.

Set up like this I chose to swap out the variable names for ones without whitespace (as the spaces only really make sense for human readability).
Alternatively you could also add %FinderInsertionLocation%/_DLVR directly into the three actions within the If/Then, as well as into the condition of the If/Then itself (in place of %Variable%local__finderLocation%/%Variable%local__folderName%)

If folder exists at this Finder location- open it. If not- create it v1.1.kmmacros (3.9 KB)

Summary

Amazing, works perfectly. Thanks so much!

1 Like