Get-Content and New-Item -ItemType Directory. This procedure works identically in the built-in Windows PowerShell 5.1 environment shipped with every supported edition of Windows 10 and Windows 11, as well as cross-platform PowerShell 7.x. Combining Join-Path and Test-Path ensures that PowerShell builds clean directory paths inside your chosen parent folder, ignores blank lines in your list, and skips any folder that already exists without modifying or deleting existing files.
Prerequisites and Windows Naming Rules
Before creating your folder list and running PowerShell commands, verify that your target location and proposed folder names meet Windows file system requirements:
- Permissions: A standard user account can create folders inside user profile locations (
C:\Users\<Username>\Documents,Desktop, or custom folders on secondary drives where your account has Modify or Write permissions). Creating folders inside system-protected locations such asC:\Program Files,C:\Windows, or the root of the system drive (C:\) requires an elevated PowerShell session (Run as administrator). - Plain-text list format: Your source file must be an unformatted plain text file (
.txt) saved in UTF-8 encoding. Do not use Word documents (.docx) or Rich Text Format (.rtf) files, asGet-Contentwill read document formatting metadata as literal characters. - Disallowed characters: Microsoft's Win32 file naming specification prohibits nine reserved characters in folder names:
<(less than),>(greater than),:(colon),"(double quote),/(forward slash),\(backslash),|(vertical bar or pipe),?(question mark), and*(asterisk). Note that if a line in your text file contains a backslash (\) or forward slash (/), PowerShell treats that line as a nested relative path (such as2026\Invoices) rather than a single folder name. - Reserved device names: Windows forbids folders named
CON,PRN,AUX,NUL,COM1throughCOM9, andLPT1throughLPT9(as well as superscript digit variants). - Trailing characters and path length: Do not end a folder name with a space or a period (
.), as the Windows shell strips or misinterprets them. Keep the combined full path (parent directory path plus the new folder name) under the 260-character Win32 maximum path limit unless long paths are explicitly enabled on the system.
Prepare the Text File and Parent Folder
Start by creating the parent folder that will hold your new directories and the plain text file containing the list of folder names.
- Open File Explorer (
Win + E) and navigate to or create the parent folder where you want the batch of new folders to live. For this guide, the examples useC:\Projects\ClientFoldersas the parent folder. - Open Notepad by pressing
Win + R, typingnotepad, and pressing Enter. - Type or paste your desired folder names into Notepad so that each folder name is on its own separate line. Spaces, hyphens, underscores, and parentheses are allowed:
Code:01 - Project Charter 02 - Contracts and Legal 03 - Design Assets 04 - Financial Reports 05 - Deliverables Archive [Final] - In Notepad, click File > Save as.
- Navigate to a convenient location—either inside
C:\Projectsor right insideC:\Projects\ClientFolders—and set Save as type to *Text Documents (.txt)**. - Set Encoding (located near the Save button in both Windows 10 and Windows 11 Notepad) to UTF-8.
- Name the file
FolderList.txtand click Save. In our example, the full path to the text file isC:\Projects\FolderList.txt.
Create the Folders with Windows PowerShell
The safest way to create folders from a text list is to iterate through each non-empty line, combine the parent path and folder name using Join-Path, check whether the target path already exists with Test-Path, and create only missing folders.
Step 1: Open Windows PowerShell
Choose the launch method for your Windows version:
- Windows 11: Right-click the Start button and select Terminal (or Terminal (Admin) if writing to a protected system path). Ensure the active tab dropdown in the title bar is set to Windows PowerShell or PowerShell.
- Windows 10: Right-click the Start button and select Windows PowerShell (or Windows PowerShell (Admin) if writing to a protected system path).
Step 2: Preview the Operation Using -WhatIf
Before creating decenas or hundreds of directories on disk, run a dry-run preview using PowerShell's -WhatIf switch. This validates your file path and shows the exact folder paths PowerShell will generate without modifying the drive.
- Copy the following block, adjust
$ListFileand$ParentFolderif you saved your file or folder in a different location, paste it into the PowerShell window, and press Enter:
Code:$ListFile = "C:\Projects\FolderList.txt" $ParentFolder = "C:\Projects\ClientFolders" Get-Content -LiteralPath $ListFile | ForEach-Object { $FolderName = $_.Trim() if (-not [string]::IsNullOrWhiteSpace($FolderName)) { $TargetPath = Join-Path -Path $ParentFolder -ChildPath $FolderName if (-not (Test-Path -LiteralPath $TargetPath)) { New-Item -Path $TargetPath -ItemType Directory -WhatIf } else { Write-Host "Skipping existing path: $TargetPath" -ForegroundColor Yellow } } } - Review the output in the console. For every new folder, PowerShell prints a message reading:
What if: Performing the operation "Create Directory" on target "Destination: C:\Projects\ClientFolders\01 - Project Charter". - Verify that the destination paths point inside your intended parent folder and that no stray text or garbled characters appear.
Step 3: Execute the Folder Creation
Once the preview confirms the target paths are accurate, run the command without -WhatIf to create the folders.
Warning: Always make sure-ItemType Directoryis explicitly included in yourNew-Itemcommand. WhileNew-Itemwith-ItemType Directorywill never erase an existing folder's contents—even if you add the-Forceswitch—runningNew-Item -ItemType File -Forceagainst an existing file overwrites that file with an empty zero-byte file. UsingTest-Path -LiteralPathas shown below prevents collisions with both existing folders and existing files of the same name.
- Run the live creation block in your PowerShell session:
Code:$ListFile = "C:\Projects\FolderList.txt" $ParentFolder = "C:\Projects\ClientFolders" Get-Content -LiteralPath $ListFile | ForEach-Object { $FolderName = $_.Trim() if (-not [string]::IsNullOrWhiteSpace($FolderName)) { $TargetPath = Join-Path -Path $ParentFolder -ChildPath $FolderName if (-not (Test-Path -LiteralPath $TargetPath)) { New-Item -Path $TargetPath -ItemType Directory | Out-Null Write-Host "Created: $TargetPath" -ForegroundColor Green } else { Write-Warning "Already exists (skipped): $TargetPath" } } } - Wait for the command to finish. For a list of a few dozen or a few hundred folders, execution completes in less than a second. Each newly created folder prints in green (
Created: ...), and any folder that already existed prints a yellow warning (WARNING: Already exists (skipped): ...).
How This Command Protects Existing Folders
$_.Trim()andIsNullOrWhiteSpace: Strips accidental leading or trailing spaces from each line inFolderList.txtand ignores blank lines at the middle or bottom of the file. Without this check, an empty line in the text file causesJoin-Pathto point at$ParentFolderitself.Join-Path: Combines$ParentFolderand$FolderNamewith a single backslash regardless of whether you typed a trailing backslash in$ParentFolder.Test-Path -LiteralPath: Checks whether an item with that exact name already exists before callingNew-Item. Using-LiteralPathinstead of-Pathensures that folder names containing square brackets (such asArchive [Final]) are treated as literal characters rather than PowerShell wildcard patterns.| Out-Null: Suppresses PowerShell's default table output for each directory object so you get a clean, readable line-by-line status report.
Verify the Results
After running the script, you can confirm straight from PowerShell that every folder listed in your text file now exists inside the parent directory.
- To list all folders currently inside the parent directory, run:
Get-ChildItem -LiteralPath $ParentFolder -Directory | Select-Object Name, CreationTime - To run an automated audit that compares every line in
FolderList.txtagainst the parent directory and reports whether each folder isPresentorMissing, run:
Code:Get-Content -LiteralPath $ListFile | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | ForEach-Object { $Name = $_.Trim() $CheckPath = Join-Path -Path $ParentFolder -ChildPath $Name [PSCustomObject]@{ FolderName = $Name Exists = (Test-Path -LiteralPath $CheckPath -PathType Container) FullPath = $CheckPath } } | Format-Table -AutoSize - Check the
Existscolumn in the resulting table. Every folder from your list should displayTrue. If an entry showsFalse, either the name contained an invalid character that prevented creation, or a file (rather than a folder) already occupied that exact name.
Alternate Method: One-Line Command for Nested Folder Trees
If your text file contains multi-level relative paths (such as 2026\Q1\Invoices, 2026\Q1\Receipts, 2026\Q2\Invoices) or if you just want a compact one-liner for a clean list, you can use New-Item -ItemType Directory -Force.
According to Microsoft Learn's documentation for New-Item, when -ItemType Directory is paired with the -Force switch, PowerShell behaves safely in two ways:
- It automatically creates any missing intermediate parent folders in a nested path.
- If a folder already exists,
New-Item -ItemType Directory -Forcedoes not overwrite, empty, or replace the existing folder; it leaves all existing files inside the folder intact and simply returns the existing directory object.
Run this one-liner to create either flat or nested directory structures from your text file:
Get-Content -LiteralPath "C:\Projects\FolderList.txt" | Where-Object { $_.Trim() } | ForEach-Object { New-Item -Path (Join-Path "C:\Projects\ClientFolders" $_.Trim()) -ItemType Directory -Force }
Use the primary Test-Path procedure from the previous section when you want explicit console warnings showing which folders already existed versus which folders were newly created. Use this -Force one-liner when you simply want to ensure all folders and subfolders in a list exist on disk regardless of prior state.
Troubleshooting Common Failures and Rollback
Symptom-to-Fix Mapping
- Error:
New-Item : An item with the specified name ... already exists.- Cause: You ran
New-Item -ItemType Directorywithout checkingTest-Pathfirst and without the-Forceparameter, and one of the folders in your list was already on disk. - Fix: Use the
if (-not (Test-Path -LiteralPath $TargetPath))wrapper from the primary procedure, or append-ForcetoNew-Item -ItemType Directory. Neither approach deletes existing files inside the directory.
- Cause: You ran
- Error:
New-Item : The filename, directory name, or volume label syntax is incorrect.orIllegal characters in path.- Cause: A line in your text file contains one of the reserved Windows characters (
< > : " | ? *). In Windows PowerShell 5.1, passing a colon (:) inside a folder name can also triggerNotSupportedException(The given path's format is not supported). - Fix: Open your text file and remove the disallowed punctuation, or strip illegal characters automatically inside the loop before
Join-Pathby sanitizing$FolderName:
Code:$InvalidChars = [IO.Path]::GetInvalidFileNameChars() -join '' $CleanName = $FolderName -replace "[$([Regex]::Escape($InvalidChars))]", "_"
- Cause: A line in your text file contains one of the reserved Windows characters (
- Folders with
[or]in their names fail to create or report strange path errors- Cause: In PowerShell,
-Pathtreats square brackets ([ ]) as wildcard character ranges. WhenNew-Item -PathorTest-Path -Pathencounters a name likeProject [2026], it attempts to resolve[2026]as a wildcard. - Fix: For
Test-PathandGet-Content, always use-LiteralPathinstead of-Path. If your folder list contains square brackets andNew-Item -Pathfails on them, pass the parent folder to-LiteralPath(or-Pathif the parent has no brackets) and the new folder name to the-Nameparameter:
New-Item -LiteralPath $ParentFolder -Name $FolderName -ItemType Directory
- Cause: In PowerShell,
- Accented characters, umlauts, or non-Latin characters appear scrambled in folder names
- Cause: Windows PowerShell 5.1 defaults to the system's legacy Windows-1252/ANSI code page when reading files that lack a Byte Order Mark (BOM), whereas modern Notepad saves files as UTF-8 without BOM.
- Fix: Add
-Encoding UTF8to theGet-Contentcommand:
Get-Content -LiteralPath $ListFile -Encoding UTF8
- PowerShell creates nested subfolders instead of a single folder name
- Cause: A folder name in your text file contains a forward slash (
/) or backslash (\), such asAccounts Receivable / Payable. Windows interprets both slashes as directory separators. - Fix: Replace
/or\in your text file with a hyphen (-) or underscore (_), such asAccounts Receivable - Payable.
- Cause: A folder name in your text file contains a forward slash (
Rolling Back Accidental Folder Creation
If you specified the wrong $ParentFolder (for example, dumping 100 folders onto your Desktop or into C:\Projects instead of C:\Projects\ClientFolders) and need to remove the folders created from the text file, you can use the same text file to clean them up.
Warning: The rollback command below deletes only empty folders that match the names in your text file. It purposefully omits the-Recurseparameter so that if your list happened to contain the name of an existing folder that already held files or subfolders, PowerShell will refuse to delete it cleanly rather than wiping out your data.
- Run the following script to remove only empty folders matching
FolderList.txtfrom the target parent folder:
Code:$ListFile = "C:\Projects\FolderList.txt" $WrongParentFolder = "C:\Projects" Get-Content -LiteralPath $ListFile | ForEach-Object { $FolderName = $_.Trim() if (-not [string]::IsNullOrWhiteSpace($FolderName)) { $TargetPath = Join-Path -Path $WrongParentFolder -ChildPath $FolderName if (Test-Path -LiteralPath $TargetPath -PathType Container) { $ItemCount = (Get-ChildItem -LiteralPath $TargetPath -Force | Measure-Object).Count if ($ItemCount -eq 0) { Remove-Item -LiteralPath $TargetPath -Force Write-Host "Removed empty folder: $TargetPath" -ForegroundColor Cyan } else { Write-Warning "Skipped non-empty folder ($ItemCount items inside): $TargetPath" } } } } - Verify in File Explorer or with
Get-ChildItem -LiteralPath $WrongParentFolderthat the stray empty folders have been removed while all populated directories remain untouched.