DEV Community

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

Posted on

1 2

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay