DEV Community

Cover image for Create multiple folders at once on the terminal
Peyman Eskandari
Peyman Eskandari

Posted on

Create multiple folders at once on the terminal

I think you are familiar with the problem. You start a new project and to make the structure you should do something like this:

mkdir new-project && cd new-project
mkdir src && cd src

// Create folders
mkdir components
mkdir assets
mkdir configs
mkdir locales
// ...
// WHAT THE HELL?

This is so frustrating! There should be a better solution 🤔

Solution

You can use this syntax to create multiple folders in a directory at once. Plain and simple:

mkdir -p new-project/src/{components,assets,configs,locales}

😲 Just that?
Yes, just that. But let's review what happened here:

  • You use -p to create sub-directories and on each level, if it doesn't exist, it makes sure that it will be.

  • Then with {} you pass a comma-separated list of names to create multiple directories beside each other.


Wasn't that bad, hah?

Problem solved

Top comments (0)