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
Asked
Active
Viewed 2,210 times
2
-
1Does this answer your question? [Is there a way to batch rename files to lowercase?](https://superuser.com/questions/65302/is-there-a-way-to-batch-rename-files-to-lowercase) – harrymc Jul 29 '20 at 15:43
-
No, sorry. I already looked at that but that command can only rename the files in a single folder at a time and I have a lot of folders sadly – Bluesandbox Jul 29 '20 at 16:02
-
Only a simple adaptation is needed. See below. – harrymc Jul 29 '20 at 16:11
-
I tried all of the commands below but they all return errors and all the files are still in caps – Bluesandbox Jul 29 '20 at 16:39
-
If you look closely, I think you'll see file names have changed, it's folder names that generate the `Source/Destination` error. – Keith Miller Jul 29 '20 at 18:22
4 Answers
2
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()}
Bluesandbox
- 49
- 4
0
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.
Wasif
- 7,984
- 2
- 19
- 32
-
1I tried that in the powershell command line but it just kept saying "Rename-Item : Source and destination path must be different." – Bluesandbox Jul 29 '20 at 16:23
0
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")
harrymc
- 455,459
- 31
- 526
- 924
-
Recursive version: `for /f "Tokens=*" %f in ('dir /l/b/a-d/s') do (rename "%f" "%f")` per comment in that same post since all other answers are showing recursive too. – Vomit IT - Chunky Mess Style Jul 29 '20 at 16:23
-
-
0
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}
}
Keith Miller
- 8,704
- 1
- 15
- 28
-
Um, what is key-banger? I tried the top one in powershell and it just returned errors – Bluesandbox Jul 29 '20 at 16:33
-
Using aliases to shorten the expression. What sort of error messages? Do any of the names have special characters like `$`, `[`, or `]`? – Keith Miller Jul 29 '20 at 18:02