clippertm
clippertm

Reputation: 159

script to rename all files & directories into lowercase (including unicode)

(1) I have about 200 directories, with probably a 1000 sub-directories containing 10,000 of files.

I would like to keep the names intact, but change them all to lower case, including Unicode characters such as 'É' (to 'é').

Can you advise how it could be done through PowerShell? It is my own computer and I have admin rights.

Upvotes: 0

Views: 3287

Answers (2)

David Lopes
David Lopes

Reputation: 559

The commands that I use to folders and files, I hope it helps.

for /r "G:\Teste" %D in (.) do @for /f "eol=: delims=" %F in ('dir /l/b/ad "%D"') do @ren "%D\%F" "%F"
for /r "G:\teste" %D in (.) do @for /f "eol=: delims=" %F in ('dir /l/b/a-d "%D"') do @ren "%D\%F" "%F"

Upvotes: 2

Sid
Sid

Reputation: 2676

I am sure most people can write this one but the idea is for you to write it. So we will point in the right direction.

Use Get-ChildItem with -Recurse switch to get all files and folders under a directory.

Use the ToLower() method to convert strings to lowercase.

Use Rename-Item to rename the folders or directories you want to.

I tried it and it worked for unicode as well. You may need to handle files and folders differently. I had to.

EDIT: For Files:

Get-ChildItem C:\temp -Recurse -File | ForEach-Object{ Rename-Item -Path $_.FullName -NewName $_.name.ToLower()}

Upvotes: 2

Related Questions