Rename all files in a folder to lowercase using PowerShell

Recently I needed to perform some housekeeping on a Windows folder. Part of this work required that the filenames be in lowercase. I know, in a usually case insensitive Operating System but bear with me. A search found this answer on Stackoverflow.

dir <<YOUR FOLDER HERE>> -r | % { if ($_.Name -cne $_.Name.ToLower()) { ren $_.FullName $_.Name.ToLower() } }

The answer gives a detailed explanation on how it works which I won’t repeat here. At the time of this post there was a comment stating this script will not rename folders.


Here is a folder with filenames in a variety of cases:

Start PowerShell and execute the script. In this example the script is executed from the folder which contains the files that I want to change so I use the full stop character . as a shortcut for the current folder.

dir . -r | % { if ($_.Name -cne $_.Name.ToLower()) { ren $_.FullName $_.Name.ToLower() } }  

The case of the files in the folder are now uniform

Don’t run unknown scripts from the iNtErNeT

I know you wouldn’t but before running this script, try it out in a sandbox and make sure it does exactly what you expect it to do.


Thanks to the people behind the Stackoverflow question and the answer.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.