7 Nov 2010 at 17:00 #1 rctneil rctneil 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?
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?
7 Nov 2010 at 17:20 #2 SiriusB SiriusB Soldato Joined 16 Dec 2005 Posts 14,443 Location Manchester 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.
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.
7 Nov 2010 at 17:35 #3 rctneil rctneil Associate OP Joined 31 Jan 2007 Posts 1,860 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?
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?
7 Nov 2010 at 17:56 #4 SiriusB SiriusB Soldato Joined 16 Dec 2005 Posts 14,443 Location Manchester powershell.com is a good place to start. LOADS of info on the net, just gotta Google.
7 Nov 2010 at 19:12 #5 rctneil rctneil Associate OP Joined 31 Jan 2007 Posts 1,860 How would I make it add 3 characters to the END of those folder names?
7 Nov 2010 at 19:51 #6 SiriusB SiriusB Soldato Joined 16 Dec 2005 Posts 14,443 Location Manchester PHP: Get-ChildItem "C:\path\to\top folder" -recurse | where { $_.PSIsContainer } | Rename-Item -newname { $_.Name + "ABC" } Change ABC to whatever it is you want.
PHP: Get-ChildItem "C:\path\to\top folder" -recurse | where { $_.PSIsContainer } | Rename-Item -newname { $_.Name + "ABC" } Change ABC to whatever it is you want.
7 Nov 2010 at 19:54 #7 OCdude OCdude Soldato Joined 24 Feb 2008 Posts 2,704 Location Norway I really need to learn more Powershell, especially for Exchange
7 Nov 2010 at 20:31 #8 SiriusB SiriusB Soldato Joined 16 Dec 2005 Posts 14,443 Location Manchester 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!
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!