Renaming multiple windows folders and subfolders with Powershell

Quentin Ikuta
1 min readJan 13, 2021

Use Case: Iterating over folders within a specified directory location, finding and replacing certain text with new text.

My example: I copied over a bunch of folders and subfolders from a directory location to a new location. The subfolders all had “2020” in the name. Now, it is 2021 and I need those folders to reflect such. There were about 300+ folders to rename and I wasn’t about to manually make those changes.

Here is where Powershell comes into play.

Using this code I was able to iterate over all the folders and the subfolders within a specified directory location and rename the folders from 2020 to 2021:

Get-ChildItem -Path C:\Example\test -Recurse | Rename-Item -NewName { $_.name -replace “text to replace”, “replacement text” }

To use this code: open up Powershell IDE, copy and paste the code, replace the path with your path, specify the text to replace and the replacement text (keeping the quotes) and hit run.

Best of luck! Have fun. Be safe.

--

--

Quentin Ikuta

2021–2022 Community Volunteer Ambassador with the National Park Service at the Mississippi National River and Recreation Area.