Create multiple directories at once with mkdir (Linux – Ubuntu)

We have listed some commands that will allow you to create multiple directories with the mkdir command.

The mkdir commands should be used wisely as they could create hundreds of directories within a couple of seconds.

The commands work in all Linux environments and they can be executed via a bash file or the terminal.

The first and most simple one is the mkdir command that uses multiple arguments to create directories.

mkdir myfirstdirectory myseconddirectory mythirddirectory

The command above uses the arguments as directory names. You can add as many names as you want, but if you really want to create hundreds of directories with just a single command, then you might want to take a look at the following list.

mkdir folder{1..50}

50 folders from folder1 to folder50

mkdir -p folder{1..50}/folder{1..50}

50 folders will be created by the following order; folder1 to folder50 (-p will create parent directories if they do not exist.

mkdir {a-z}123

26 directories from a123 to z123

mkdir {1,2,3}

Creates the folders 1, 2 and 3.

mkdir test{01..20}

            20 directories from test01 to test20

mkdir -p `date '+%y%m%d'`/{1,2,3}

Adds the date to the folder name.

mkdir -p $USER/{1,2,3} 

Adds the current user name to the folder.

If you have a list of folder names then you can simply do:

mkdir `cat list`

This will create a folder for each line in the provided list.