Create multiple directories all at once in Windows 10

Sometimes, you need to create multiple folders at once sequentially named. For example, you might want to create directories named dir1, dir2, dir3 ... dirN. Using built-in tools of Windows 10, you can save your time and create them all at once. Here is how it can be done.

Windows 10 offers you two tools to automate the process. The first tool is PowerShell and the second one is Bash on Ubuntu. Let's see both ways.

Create multiple directories using PowerShell

  1. Open PowerShell in the desired folder. Tip: see the article All ways to open PowerShell in Windows 10.
  2. Type the following command in Powershell:
    mkdir $(1..20 | %{"dir$_"})

    The output will be as follows:
    windows-10-create-mutiple-directories-with-powershell

This will create 20 directories named dir1 - dir20. See the following screenshot:

windows-10-mutiple-directories-with-powershellCreate multiple directories using Bash On Ubuntu

You can do the same using the built-in Windows Subsystem for Linux. If you don't have it installed, see the following article:

How to enable Ubuntu Bash in Windows 10

Now, you need to run it and navigate to the desired folder. Use the "cd" command to reach the desired folder in the bash console. In Bash on Ubuntu, all Windows drives are connected as mount points as mentioned below:

/mnt/c/mnt/d

And so on.

mounted-drivesSo, to access my user profile, I need to type the following command:

cd /mnt/c/Users/winaero/Documents

The result will be as follows:

cd-windows-foldersNow, you can use the Linux mkdir command to create multiple directories using the following syntax:

mkdir dir{1..20}

See the following screenshot:

create-dirs-with-bash

Tip: if you use Bash on Ubuntu frequently, you can add it to Explorer's context menu. See Add Bash to the folder context menu in Windows 10

That's it.

Advertisment

5 thoughts on “Create multiple directories all at once in Windows 10

  1. Долматов Алексей

    Basic CMD comand (Description is available in the standard help)
    Create folder from 3 to 20 in increments of 4
    for /L %i IN (3,4,20) do mkdir dir%i

    Reply
  2. Anton

    Or, if you don’t want directories with consecutive names, just create them all in one mkdir command in cmd:
    mkdir alpha beta gamma delta epsilon

    Reply
  3. Sultan

    Amazing! Thank you so much, I needed to create 500+ folders and I did it in less than 2 minutes. You probably saved me hours and hours of work.

    Reply
  4. Anthony Salas

    This works great. Thank you. Is there a way to have it show 0’s in the file name? I am creating mass vehicle folders. In this case 24-001 up to 24-269. It created folders 24-1, 24-2 and so on. Thanks in advance.

    Mkdir $(001..269 | %{“24-$_”})

    Reply
    1. Anthony Salas

      Answered my own question.

      md -Name $_ $(0..269 | % { “24-{0:000}” -f $_ } )

      Thanks!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *