Automate Folder structure

Hi there. Im quite new on Keyboard Maestro. I work a lot with different projects and would love to create a automated folder structure Macro.

Something like this:

Prompt for user input
Project1, Project2, Project3

When I have selected a Project I want a Window to appear where I can write a Topic:

SamsungAct

And with this new folder topic I also want a Check box window appear, with often used folders can be selected:

/Sounds
/Movies
/Texts
/Graphics
/Ideas
/Scripts
/“new folder” (a new folder name)

Now if I check the boxes for /Sounds and /Texts in the Project2 with the new topic SamsungAct, I want this folder structure to appear:

/Dropbox/Project2/SamsungAct/Sounds
/Dropbox/Project2/SamsungAct/Texts

Have you guys figured out a way to make such a Macro?

All the best. Eriko

Hey Erik,

That can be done.

Look here for user input:

https://wiki.keyboardmaestro.com/action/Prompt_for_User_Input

Here's how to get the path of your Dropbox folder if it's not in the default location.

(Note that you can open this and see the full post or go-to the thread itself.)

The default path for Dropbox is:   ~/Dropbox

Basically your goal is to compile a path-string using component parts.

Then you can create the directory structure with 1 Execute a Shell Script action.

Your hierarchy:

mkdir -p ~/Dropbox/Project2/SamsungAct/Sounds

More than 1 subdirectory in a given subdirectory:

mkdir -p ~/Dropbox/Project2/SamsungAct/{src,doc,tools,db,Sounds/Seascape}

The -p switch causes mkdir to create directories that don't already exist.

Without that switch the command will fail if any subdirectory in the chain is missing (except the last one of course).

-Chris

Thanks Chris!

I got your Shell script actions to create the folders. The thing I'm struggling with is how to make the flexibility in choosing:

Make the "/SamsungACT/" to be a changeable topic, like the "default value" in the example you liked. So that i can create a new Topic with every project I'm working on:

And also that the "Check box on" = 1|0 will have impact on witch subfolders that will be created:

If all these three Promts could affect your shell script the idea would leave the idea phase and become a real tool :smile:

mkdir -p ~/Copy/~/"defaultvalue"/{Sounds,Movies}

All the best. Eriko

Hey Erik,

I gave you the pieces to construct a real tool.  :smile:

You can concatenate variables, so this sort of thing is relatively simple.

There are various pitfalls to watch out for when assembling shell scripts.

KM user-input is takes a bit of experimentation, before you understand its subtleties.

In the macro below I've tried to demonstrate all of the various input forms. If your Dropbox folder is in the default location it should just work.

* Note: Keyboard Maestro has a Custom HTML Prompt action, so if you know HTML, CSS, and JavaScript you can get really fancy.

-Chris


User Input Creates Collection of Folders.kmmacros (12 KB)

1 Like

Oh. Thanks again Chris. I have had a few hours to play around with your example. And got the picture of how to achieve the folder structure. Still not there completely but thanks a lot for a great tool to start from!

/Eriko