Skip to main content
ubuntuask.com

Back to all posts

How to Change Multiple Folder Names In Powershell?

Published on
4 min read
How to Change Multiple Folder Names In Powershell? image

Best PowerShell Command Tools to Buy in October 2025

1 Learn Windows PowerShell in a Month of Lunches

Learn Windows PowerShell in a Month of Lunches

BUY & SAVE
$31.99 $44.99
Save 29%
Learn Windows PowerShell in a Month of Lunches
2 PowerShell in Depth

PowerShell in Depth

BUY & SAVE
$59.99
PowerShell in Depth
3 Learn Windows PowerShell in a Month of Lunches

Learn Windows PowerShell in a Month of Lunches

BUY & SAVE
$40.91 $44.99
Save 9%
Learn Windows PowerShell in a Month of Lunches
4 PowerShell with SharePoint from Scratch: Exercises and Explanations (Microsoft Tech from Scratch)

PowerShell with SharePoint from Scratch: Exercises and Explanations (Microsoft Tech from Scratch)

BUY & SAVE
$9.99
PowerShell with SharePoint from Scratch: Exercises and Explanations (Microsoft Tech from Scratch)
5 PowerShell in Depth: An Administrator's Guide

PowerShell in Depth: An Administrator's Guide

BUY & SAVE
$105.84
PowerShell in Depth: An Administrator's Guide
6 Instant Windows PowerShell 3.0 Windows Management Instrumentation Starter

Instant Windows PowerShell 3.0 Windows Management Instrumentation Starter

BUY & SAVE
$21.99
Instant Windows PowerShell 3.0 Windows Management Instrumentation Starter
7 Microsoft Exchange Server PowerShell Cookbook - Third Edition

Microsoft Exchange Server PowerShell Cookbook - Third Edition

BUY & SAVE
$51.99
Microsoft Exchange Server PowerShell Cookbook - Third Edition
+
ONE MORE?

To change multiple folder names in PowerShell, you can use the Rename-Item cmdlet. You can specify the folders you want to rename by using wildcards or specifying multiple folder names separated by commas. Here's an example of how you can rename multiple folders at once:

# Rename folders using wildcards Get-ChildItem -Path "C:\Path\To\Folders" -Directory | Where-Object { $_.Name -like "Folder*" } | ForEach-Object { Rename-Item -Path $_.FullName -NewName ("NewName_" + $_.Name) }

Rename specific folders

Rename-Item -Path "C:\Path\To\Folders\Folder1", "C:\Path\To\Folders\Folder2" -NewName "NewName1", "NewName2"

Make sure to replace the folder paths and names with your actual folder paths and new names. This script will rename all folders that match the specified wildcard pattern or specified folder names with the new names you provide.

How to rename folders based on their attributes in PowerShell?

You can use the following PowerShell script to rename folders based on their attributes:

# Get a list of folders in the specified directory $folders = Get-ChildItem -Path "C:\Path\To\Directory" -Directory

Loop through each folder

foreach ($folder in $folders) { # Get the attributes of the folder $attributes = $folder.Attributes $newName = ""

# Check the attributes and rename the folder accordingly
if ($attributes -band \[System.IO.FileAttributes\]::Archive) {
    $newName = "Archive\_$($folder.Name)"
}
elseif ($attributes -band \[System.IO.FileAttributes\]::ReadOnly) {
    $newName = "Readonly\_$($folder.Name)"
}
elseif ($attributes -band \[System.IO.FileAttributes\]::Hidden) {
    $newName = "Hidden\_$($folder.Name)"
}

# Rename the folder
if ($newName -ne "") {
    Rename-Item -Path $folder.FullName -NewName $newName
    Write-Host "Renamed $($folder.Name) to $newName"
}

}

Replace "C:\Path\To\Directory" with the path to the directory containing the folders you want to rename. Update the conditions in the script based on the attributes you want to use for renaming the folders.

Run the script in PowerShell to rename the folders based on their attributes.

What is the best way to remove certain characters from folder names in PowerShell?

The best way to remove certain characters from folder names in PowerShell is to use the Rename-Item cmdlet. Here is an example of how you can remove certain characters from folder names:

  1. Open PowerShell.
  2. Navigate to the folder containing the folders with the characters you want to remove.
  3. Use the following command to remove certain characters from the folder names:

Get-ChildItem | ForEach-Object {Rename-Item $_.FullName $_.Name.Replace("CharacterToRemove", "")}

Replace "CharacterToRemove" with the specific character or characters you want to remove from the folder names. This command will iterate through each folder in the directory and remove the specified characters from the folder names.

Remember to always test the command on a sample directory or backup before running it on important folders to avoid any accidental data loss.

What is the command for changing the case of folder names in PowerShell?

To change the case of folder names in PowerShell, you can use the following command:

Get-ChildItem | % { Rename-Item $_ $_.Name.ToLower() }

This command will retrieve all child items (folders and files) in the current directory and then rename each folder to lowercase. You can replace .ToLower() with .ToUpper() if you want to change the folder names to uppercase instead.

How to replace specific characters in folder names in PowerShell?

To replace specific characters in folder names in PowerShell, you can use the following script:

# Specify the path to the folder where you want to replace characters $path = "C:\Path\To\Folder"

Get a list of folders in the specified directory

$folders = Get-ChildItem $path -Directory

Loop through each folder and replace the specific characters

foreach ($folder in $folders) { # Replace the specific character with desired character $newName = $folder.Name -replace "oldCharacter", "newCharacter"

# Rename the folder
Rename-Item -Path $folder.FullName -NewName $newName

}

Replace oldCharacter with the character you want to replace and newCharacter with the character you want to replace it with. Save this script as a .ps1 file and run it in your PowerShell terminal. It will go through each folder in the specified directory and replace the specified character in the folder name.