deva deva - 1 year ago 59
PowerShell Question

powershell - want to chnage bulk files name into Title Case

I have bulk image files, i just want to change files name into Title Case via powershell.
For ex:

file name like this.jpg into File Name Like This.jpg

I have 700+ files in sub folders. Please help me in this.
i try this code
Get-ChildItem "C:\temp\new" -recurse |Where {-Not $_.PSIsContainer} |Rename-Item -NewName {$_.FullName.TOUPPER()}

But this code makes all latter's into capital.

Answer Source

So PowerShell actually has a super simple way to do that using Get-Culture's textinfo. That property contains a method called ToTitleCase() which will do exactly (almost) what you want. The only difference being that it will also capitalize the 'J' in 'Jpg'. Just the extension though, so no big deal right?

$Culture = Get-Culture
Get-ChildItem "C:\temp\new" -recurse |Where {-Not $_.PSIsContainer} |Rename-Item -NewName {$Culture.textinfo.totitlecase($_.FullName)}