Batch change folder names

Associate
Joined
31 Jan 2007
Posts
1,860
Hey

I have a folder and want to remove the first 2 characters of the name of every subfolder within.

How can I do this quickly in bulk?
 
Open up a Powershell console [assuming you are on Windows 7]

Type this in and hit enter:

PHP:
Get-ChildItem "C:\path\to\top folder" -recurse | where { $_.PSIsContainer } | Rename-Item -newname { $_.Name.Substring(2) } -whatif

Check the output is what you expect, then run it again without the -whatif at the end.
 
perfect. Thanks

Had to change it from 2 to 1. I thought each foldername had a space as well but it didn;t so changed it to 1 character and it works perfectly.

Is there anywhere I can learn more about Power Shell?
 
PHP:
Get-ChildItem "C:\path\to\top folder" -recurse | where { $_.PSIsContainer } | Rename-Item -newname { $_.Name + "ABC" }

Change ABC to whatever it is you want.
 
None of my clients use Exchange 2007 or 2010, so haven't had any reason to play. They're all too tight to upgrade too! :(

2003 is a pain with Powershell. You have to delve into WMI and such!
 
Back
Top Bottom