How to rename all the files and folders of files in a folder to have lower case names at once?

I have a folder with a bunch of textures and things that I need to rename to lower case, is there any way to rename all the files and folders of files in this folder to have lower case names at once? edit: this is different from the similar post because the command from that answer will only do it for one folder at a time, not all the folders in the top folder

5

4 Answers

I found this in a comment on the simalar post that at first i thought only renamed things in the foler its executed in. It seems to work

 Get-ChildItem "C:\path\to\folder" -recurse | Where {-Not $_.PSIsContainer} | Rename-Item -NewName {$_.FullName.ToLower()} 

Try this powershell code:

Get-childItem "Filepath" -Recurse | Rename-Item -NewName {$_.Basename.tostring().tolower() + $_.extension} 

This will recursively rename all files and folders in "Filepath" to lower case.

1

Based on Is there a way to batch rename files to lowercase, here is a formulation that does files and folders recursively:

for /f "Tokens=*" %f in ('dir /l/b/s') do (rename "%f" "%f") 
3

PowerShell: Verbose, Files

$Source = 'c:\TopFolder' ( Get-ChildItem $Source -File -Recurse ) | Rename-Item -NewName { $_.Name.ToLower() } 

Key-Banger, Files:

(gci 'c:\TopFolder' -af -r) | ren -new { $_.Name.ToLower() } 

For folders, to avoid Source/Destination errors, you have to rename to a temp value as an intermediate step. Here's one way:

gci -ad -Recurse | %{ $Lower = $_.Name.ToLower() $_ | ren -new {(Get-Date).Ticks } -passthru | ren -new {$Lower} } 
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like