# Creating Multiple Folders at Once on Linux


As a Linux user, you may often find yourself needing to create multiple new folders for organizing projects or data. However, having to manually create each folder one by one can become tedious.

Thankfully, Linux provides a handy built-in tool for easily creating multiple directories at once. Learning how to use this tool can save you time and effort while working in your Linux environment.

## The Basics of `mkdir` for Creating Directories

The `mkdir` command in Linux allows you to make new folders from the command line interface (CLI). Here is a quick overview of its basic syntax:

```plaintext
mkdir folder_name
```

This would create a new folder called `folder_name` in the current working directory.

You can also specify a full or relative file path to create a folder in a specific location, like:

```plaintext
mkdir /home/user/projects/new_folders
```

So far, pretty straightforward! But what if you need to make several folders at once?

## Using `mkdir` to Create Multiple Folders

The `mkdir` command has an option that allows you to create multiple directories in one go.

The syntax looks like this:

```plaintext
mkdir folder_name1 folder_name2 folder_name3
```

Simply list out all the new folder names, separated by spaces. This will create each one sequentially in the current working directory.

For example, to make three new folders named `reports`, `data`, and `configs` all at once, you would run:

```plaintext
mkdir reports data configs
```

Much easier than having to run `mkdir` three separate times!

You can also combine this with absolute or relative paths, like:

```plaintext
mkdir /home/user/invoices/2022 /home/user/invoices/2023 /home/user/invoices/2024
```

This allows you to create the nested folders `2022`, `2023`, `2024` directly within the `invoices` folder.

## Handy Options and Tips

There are a couple of handy options and tips to take your `mkdir` skills up another level:

### Create Intermediate Directories with `-p`

The `-p` flag tells `mkdir` to create any necessary intermediate parent directories that don't yet exist.

For instance:

```plaintext
mkdir -p /home/user/new_project/data/logs
```

This will create the `new_project` folder, the `data` folder inside of it, and then the `logs` folder inside of `data`. Extremely useful!

### Avoid Errors with Existing Folders Using `-p`

By default, `mkdir` will return an error if any of the directories you are trying to make already exist.

The `-p` flag prevents this. It will simply skip folders that are already there.

So you can just run:

```plaintext
mkdir -p folder1 folder2 folder3
```

And any that exist will be skipped while any that don't will be created. Convenient.

> Also read - [**How to Share Files Between Windows and Kali Linux**](https://developnsolve.com/how-to-share-files-between-windows-and-kali-linux)

## Recap and Conclusion

As you can see, Linux's `mkdir` command certainly makes creating multiple folders much less tedious. Here's a quick recap of what we covered:

- Use `mkdir folder_name1 folder_name2` syntax to make multiple folders at once
- Combine with paths to put new folders anywhere in the system
- `-p` option creates intermediate parent folders too
- `-p` also avoids errors from existing folders

Learning to wield `mkdir` effectively will save you a lot of hassle down the road any time you need to organize lots of new directories for your data and projects! It may seem basic, but using tools like this is what makes Linux such a cleverly efficient operating system.

Applying these folder-creation tips will surely make your time spent working in Linux more productive and enjoyable. So go out and start tidying up your digital workspace with precisely crafted folder structures! Your future self will thank you for it.

