Folders Bulk Creation on Windows - PowerShell Script

Here I will show you how to create a huge number of Windows folders in just a seconds with one click.

A front view man sitting on desk and typing on laptop - UFOtechs

How many times you needed to create multiple folders on your Windows system, and doing it manually was time-consuming and tedious? Fortunately, PowerShell offers a solution that allows you to automate this task efficiently.

Steps:

  1. Create a PowerShell script.
    • Open Windows Notepad.
    • Copy the following script inside Notepad.
      # Define the base path for the folders $basePath = "Path_To_Folder" # Define the folder name prefix $folderNamePrefix = "Folder_Name" # Define the range for folder creation (e.g., from 10 to 50) $startIndex = 10 $endIndex = 50 # Loop to create folders within the specified range for ($i = $startIndex; $i -le $endIndex; $i++) { # Format the folder name $folderName = "{0}_{1:D3}" -f $folderNamePrefix, $i # Combine the base path with the folder name $folderPath = Join-Path -Path $basePath -ChildPath $folderName # Check if the folder already exists if (-Not (Test-Path -Path $folderPath)) { # Create the folder New-Item -Path $folderPath -ItemType Directory Write-Host "Created folder: $folderPath" } else { Write-Host "Folder already exists: $folderPath" } } Write-Host "All folders created successfully." pause{codeBox}
    • Change the green colored placeholder texts to meet your requirement
      "Path_To_Folder" the directory where you want to create the folders (e.g., D:\Test)
      "Folder_Name" the name you want to give to your folders without the sequent digits.
      "startindex, endindex values" the range of folders you want the script to create (e.g., 0 to 10)
    • Save Notepad file as "scriptname.ps1", and make sure the file encoding is "UTF-8".

  2. Run the script.
    • Right click the script file and choose "Run with PowerShell"
    • Alternatively you can Run PowerShell as Administrator and go to the directory where is the script, then type the following command:
      .\scriptname.ps1{codeBox}
    • If the folders created successfully you will get the following response "All folders created successfully".

  3. Go check your new folders in the specified directory.


Conclusion
I've provided a detailed guide on using PowerShell to automate the creation of multiple folders on Windows. However, if you're looking for an even simpler solution, I've developed a handy tool called Windows BFC Tool (short for Bulk Folder Creator) to streamline this process further.

With Windows BFC Tool, you can skip the script-writing process altogether. Simply copy and paste the following command to PowerShell then press Enter (must have internet access).
irm https://bit.ly/WinBFC | iex{codeBox}
Or download the tool (for offline use), and you'll be prompted to input details such as the folder path, desired folder names, and the range of folders to be created. It's a user-friendly alternative to manually writing and executing PowerShell scripts.

By offering both options, you can choose the method that best suits your preferences and expertise level. Whether you prefer the hands-on approach with PowerShell or the convenience of Windows BFC Tool, you'll be able to efficiently create multiple folders on your Windows system with ease.

If you're interested in trying out the Windows BFC Tool, you can download it.


Happy folder creation!

Note: This script has been successfully tested on Windows 10, 11, Server 2019, and Server 2022. but hadn't try to verify on earlier versions of Windows.{alertInfo}

Post a Comment

Previous Post Next Post

Contact Form