Jump to content
  • How to bulk create folders in one try on Windows 11


    Karlston

    • 616 views
    • 9 minutes
     Share


    • 616 views
    • 9 minutes

    Do you need to create multiple folders on Windows 11? Here's a quick way to do this.

    On Windows 11 (and 10), you can create a new folder through File Explorer in multiple ways, but the only caveat is that you can only create one item at a time. However, if you're working on a project or organizing files, it's possible to create multiple folders in bulk.

     

    You can complete this task without resourcing to third-party tools using PowerShell and Command Prompt. It's also possible to create folders in different ways. For example, you can create folders with specific names, using a base name structure, and you can generate different folders extracting the names from a text file.

     

    In this how-to guide, I'll walk you through different ways to create multiple folders at once on Windows 11. (You can also use these instructions on Windows 10.)

    How to create folders with PowerShell on Windows 11

    You can leverage PowerShell in many ways to create multiple folder at once, and here are three ways to complete this task.

    Using specific names

    To create folders with specific names through PowerShell, use these steps:

     

    1. Open Start.
    2. Search for PowerShell, right-click the top result, and choose the Run as administrator option.
    3. Type the following command to open a specific location and press Entercd c:/path/to/folder 

     

    In the command, specify the path to the location where you want to create the folders. 

     

    1. Type the following command to create multiple folders on a specific location and press Enter"folder-1", "folder-2", "folder-3" | %{New-Item -Name "$_" -ItemType "Directory"} 

     

    kNeMyzPTSDTXjfRnLFPYsQ-970-80.jpg

    (Image credit: Mauro Huculak)

     

    In the command, change "folder-X" for names of the folders you want to create.

     

    Here's a breakdown of the command:

     

    • "folder-1", "folder-2", "folder-3": This part of the command specifies an array of strings, each representing a folder name you intend to create.
    •  "|": The pipeline operator takes the output from the command on its left and passes it as input to the command on its right. 
    • %{ }: This is a shorthand alias for the "ForEach-Object" cmdlet, which performs an operation for each item in a collection.
    • New-Item: This cmdlet creates a new item with the specified properties.
    • -Name "$_": Dynamically specifies the name of the new item, where "$_" is a variable that represents the current object in the pipeline.
    • -ItemType "Directory": This part specifies that the item to be created is a directory (commonly known as a "folder").

    Using structure name

    To create multiple folders with the same name structure, use these steps:

     

    1. Open Start.
    2. Search for PowerShell, right-click the top result, and choose the Run as administrator option.
    3. Type the following command to open a specific location and press Entercd c:/path/to/folder

     

    In the command, specify the path to the location where you want to create the folders. 

     

    1. Type the following command to create multiple folders with the same name structure and press Enterfor ($wc=1;$wc -le 3;$wc++){MD ".\folder-$wc"}

     

    PJVZgS4nQ5hoHrgFAohuxg-970-80.jpg

    (Image credit: Mauro Huculak)

     

    In the command, change "3" for the number of folders to create and "folder-" for the base of the folder.

     

    Here's a breakdown of the command:

     

    • for: Runs the "for" loop to control the flow statement to execute a repetitive condition.
    • $wc=1: Initializes the variable "$wc" to 1.
    • $wc -le 3: The condition for continuing the loop. "-le" stands for "less than or equal to," meaning that as long as "$wc" is less than or equal to "3," the loop will continue to execute.
    • $wc++: This increases the value of "$wc" variable by "1" with each iteration of the loop.
    • { MD ".\folder-$wc" }: Includes the command to create a folder on each loop iteration.

    Using text file 

    Before proceeding with these steps, create a file called "name-list.txt" with Notepad and make sure to create a list of the folders' names (one entry per line). 

     

    To create folders based on a list inside of a text file, use these steps:

     

    1. Open Start.
    2. Search for PowerShell, right-click the top result, and choose the Run as administrator option.
    3. Type the following command to open a specific location and press Entercd c:/path/to/folder

     

    In the command, specify the path to the location where you want to create the folders. 

     

    1. Type the following command to grab the text file with the list of names and create folders automatically and press Enterget-content C:\path\to\folders.txt | %{ if($_ -match $pattern) { mkdir "C:\path\to\folder\$_"; }} 

     

    JUkUzA2fVpB4nXyqSzcq4E-970-80.jpg

    (Image credit: Mauro Huculak)

     

    In the command, update the paths to match the locations of the text file and the folder to create the subfolders.

     

    Here's a breakdown of the command:

     

    • Get-Content C:\path\to\name-list.txt: This part of the command locates and reads the txt file.
    •  "|": The pipeline operator takes the output from the command on its left and passes it as input to the command on its right. 
    • %{ }: This is a shorthand alias for the "ForEach-Object" cmdlet, which performs an operation for each item in a collection.
    • if($_ -match $pattern) { }: This "if" statement checks if the current line "$_" matches a pattern defined by the variable "$pattern." 
    • mkdir "C:\path\to\folder\$_": This part of the command creates folders in the specified path.

     

    Once you complete the steps, the command will run, and the folders will be created according to your configuration.

    How to create folders with Command Prompt on Windows 11

    On Command Prompt, similar to PowerShell, you have many different ways to create multiple folders at once, and here are three useful ways to complete this task.

    Using specific names

    To create multiple folders through Command Prompt with specific names, use these steps:

     

    1. Open Start.
    2. Search for Command Prompt, right-click the top result, and choose the Run as administrator option.
    3. Type the following command to open a specific location and press Entercd c:/path/to/folder

     

    In the command, specify the path to the location where you want to create the folders. 

     

    1. Type the following command to create multiple folders with specific names and press Entermd folder-1 folder-2 folder-3

     

    xJSpCmBbbY4tL9eAmDzxZR-970-80.jpg

    (Image credit: Mauro Huculak)

     

    Here's a breakdown of the command:

     

    • md: This is short for "make directory." It's the command used to create a new directory on Windows.
    • folder-1 folder-2 folder-3: These are the names of the directories you want to create. 

    Using structure name

    To create multiple folders at once with the same based name and appending an identifier, use these steps:

     

    1. Open Start.
    2. Search for Command Prompt, right-click the top result, and choose the Run as administrator option.
    3. Type the following command to open a specific location and press Entercd c:/path/to/folder

     

    In the command, specify the path to the location where you want to create the folders. 

     

    1. Type the following command to create multiple folders with the same name structure and press Enter: for /L %w in (1,1,10) do mkdir folder-%w

     

    TgszKaVauvNEcQY7zkMGBM-970-80.jpg

    (Image credit: Mauro Huculak)

     

    In the command, change "10" for the number of folders you want to create. Also, in Command Prompt, for the variable, use a single letter as shown in the command example above.

     

    Here's a breakdown of the command:

     

    1. for:  Runs the "for" loop to control the flow statement to execute a repetitive condition.
    2. /L: This option specifies that the loop will repeat over multiple times.
    3. %wc: This is a variable that will hold each value.
    4. in (1,1,10): This part of the command specifies the number of folders to create. It starts at "1," increments by "1," and ends at "10."
    5. do mkdir folder-%wc: This part of the command creates folders in the specified path. 

    Using text file 

    Before proceeding with these steps, create a file called "name-list.txt" with Notepad and make sure to create a list of the folders' names (one entry per line). 

     

    To leverage Command Prompt to create multiple folders from a list on a text file, use these steps:

     

    1. Open Start.
    2. Search for Command Prompt, right-click the top result, and choose the Run as administrator option.
    3. Type the following command to open a specific location and press Entercd c:/path/to/folder

     

    In the command, specify the path to the location where you want to create the folders. 

     

    1. Type the following command to create multiple folders from a list in a text file and press Enterfor /f "tokens=*" %w in (folders.txt) do mkdir "%w"

     

    Xbe7b9nqPG97eM63L4DNVd-970-80.jpg

    (Image credit: Mauro Huculak)

     

    In the command, change "folders.txt" for the name of the text file with names you want to use.

     

    Here's a breakdown of the command:

     

    • for:  Runs the "for" loop to control the flow statement to execute a repetitive condition.
    • /f: This option means that the loop will process the output of a command or the contents of a file.
    • "tokens=*": This part of the command specifies that the entire line should be treated as a single token.
    • %wc: This is the variable that will hold each line of the file name-list.txt.
    • in (name-list.txt): This specifies the file from which to read the lines.
    • do mkdir "%wc": This part of the command creates a folder with the name specified by each line in the file.

     

    After you complete the steps, the command will create the folders according to your configuration.

     

    It's important to note that these commands are meant to be run inside the console. If you're trying to create a batch file, the variables should be written as "%%wc," not "%wc."

     

    Source

    • Thanks 1

    User Feedback

    Recommended Comments

    There are no comments to display.



    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.
    Note: Your post will require moderator approval before it will be visible.

    Guest
    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...