Create a folder with subfolders

Hello, I'm a complete Keyboard Maestro noob.

How can I create a folder with custom named subfolders? Also, is it possible to have a prompt which asks me what name I want to choose for the main folder? Thanks in advance!

Here's one way to go about doing this:

Create folders with subfolders- from prompt.kmmacros (20 KB)


Hi! Thanks for this, but I think I explained incorrectly what I want.

Here is basically what I want:

A couple of other things:

  1. How can I add a subfolder to Folder 1, 2, 3 or 4 if I want to in the future?
  2. Can I change the location the folder is created to: /Users/username/Movies/YouTube
  3. I just want to be able to rename the name of the MAIN FOLDER each time I execute the macro, all other folders should have the same name.
    Folder 1: A Roll
    Folder 2: B Roll
    Folder 3: Music
    Folder 4: Assets

I tried to do all of this manually with the macro you created, but I got really confused haha.

Thank you very much!

1 Like

@Alexander's example Macro contains all the elements you need but to help you understand what is going on here is simpler Macro that does what you ask above.

EXAMPLE Create Main Folder and Sub Folders.kmmacros (5.1 KB)

In the first two Magenta Actions you set the path to where you want to generate the folders and a list of the names of the folders you want (the list can be of any length).

The next Action Prompts you to enter a name for your "MAIN FOLDER"

The next Action is a For Each Action that is a loop - it does something for each of the lines in your list of Folders (in this case 4 folder names, so it will loop 4 times).

Within this looping Action the Purple Coloured Action is the one that does the work of making the folders and subfolders using the Variables that have been supplied in the Actions above. It is important that the gear menu of this Action has the option "Create Intermediate" checked as this will create any folders needed to make the full paths of the folders.


The full path to the new folders in the Purple Action is:

%Variable%LOCAL__Path%/%Variable%LOCAL__Main Folder%/%Variable%LOCAL__Sub Folder%

Which equates to: Path set in first Magenta Action/Name of your Main Folder/Name of each subfolder.

The final Action just opens your new MAIN FOLDER in the Finder to show the newly created folders.

The simplest way to add more subfolders in the future would be to include them as subfolders in the second Magenta Action. I quite like this way as it shows at a glance what folders are going to be created. For example:

Or you could make another list of those new Music subfolders and use another For Each Loop to create them - there are endless possibilities to customise the Macro to your needs. Hope this helps!


Wow, thank you for taking the time to explain everything. I highly appreciate it! I'll have to reread your comment a couple of times to understand it, but at least now I somewhat grasp what happens. Cheers!


For a general approach, see also:


And just to further simplify what is going on (stripping out the prompts and variables and loops):

EXAMPLE Create Main Folder and Sub Folders v2.00.kmmacros (3.4 KB)


Thanks for clarifying and I now see what you wanted. With @Zabobon's great explanation and example macros I am sure you'll be able to tailer a macro to suit your needs perfectly. And @ComplexPoint's script based macro is a much better solution for complex folder structures, but I anyways wanted to make a version of my above macro that can both create different parallell subfolders at top level in Main Folder (different "branches" delimited by a colon ":" in the Subfolder Structure prompt field) — as well as subfolders within these branches (delimited by forward slash “/“)

To get your four example folders as top level subfolders within you MAIN FOLDER you'd fill in the Subfolder Structure prompt field with A Roll:B Roll:Music:Assets.

But with this version of the macro you could also set up slightly more complex folder structures, like A Roll/Proxies:B Roll/Proxies:Music:Assets/Asset 1/Subfolder. Sadly this macro does not directly support setting up branches within branches. For this you’d have to run it again, appending the Directory with “/Your Last Main Folder Name”, and for instance setting Main Folder Name to A Roll and Subfolder Structure to Card 1:Card 1:Card 2:Card 3 or something like that.

As with my last version also this macro uses one global variable, but this is done deliberate as it makes sense to me to have the last entered values displayed as default values in the prompt.

Create folders with subfolders- from prompt v1.1.kmmacros (25 KB)

Macro Image


Thank you for this!

1 Like


Made a vesion of the scripted approach @ComplexPoint linked to above, now implementing a Prompt for snippet interface, among some other aditional features. Uploaded it in this thread here: Create a nested folder structure based on a plain text outline

1 Like