How to lowercase a string except for first character with powershell -
How to lowercase a string except for the first character with pars?
Get-ChildItem - R. where {! $ _ PSIsContainer} | Rename-Item -NewName {$ _FullName.substring (0,1) .toupper () + $ _FullName.substring (1) .tolower ()}
Accidents, how to fix? $ _ and property.
The other problem is that the absolute name
is the complete path of the object including the drive and the path, so the first character creates the uppercase only the drive letter uppercase (which was already there) Nothing changes, instead using the name
property will work because it does not have a path and will use the path from the rename-item
original item without path.
The third small problem is that you can filter Get-ChildItem to give only the file and no other step is needed:
Get-ChildItem -recurse - File | Rename-Item -NewName {$ _. Name.substring (0,1) .toupper () + $ _ Name.substring (1) .tolower ()}
Instead of just the first letter uppercase, you actually want to uppercase the words in the file name. If so, you can do it instead:
Go- ChildItem -recurse -File | [Edit] However, it also makes the extension uppercase, so it is actually better: << Get -TitleCase ($ _.)}
/ P>
Go-ChildItem -recurse -File | Rename-Item -NewName {(Get-Culture) TextInfo.ToTitleCase ($ _ BaseName) + $ _ Extension. ToLower ()}
Comments
Post a Comment