# Is there a way to batch rename files to lowercase?

I need a way to rename all files in folders and subfolders to lowercase.

I'd like to know if there is a way to do that using only windows (XP or 7)

-
windows doesn't differentiate between small and upper caps as unix does. maybe, if you said, why you need this, it would help in solving the problem. –  Rook Nov 4 '09 at 0:47
@Idigas. Sorry, but since NTFS, filenames have been case sensitive. See support.microsoft.com/kb/100625 –  DaveParillo Nov 4 '09 at 6:49
Just great. Take a bad idea and spread it further. What a support nightmare when someone sends a file and a fat finger mistake means they sent "Answers.dat" and the incoming process expects "answers.dat". There's just no good reason for those two names to be considered 'different'. –  David Nov 4 '09 at 12:45
@David, for example Java actually requires case-sensitive file names. That can yield a lot of trouble on non-case-sensitive file systems. –  Arjan Nov 4 '09 at 17:26
I know this is old, but I wanted to clarify a misconception here. While NTFS supports case sensitivity, the Windows OS DOES NOT differentiate! –  geo Jan 23 '13 at 20:37

Go to the directory and run the following command:

for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")

-
Recursive version: for /f "Tokens=*" %f in ('dir /l/b/a-d/s') do (rename "%f" "%f") (added /r to dir). –  Sawny Feb 13 '13 at 18:20
this is just briliant –  Shir Gans Apr 4 '13 at 18:27
very nice, thanks :) –  Bob Davies Jul 18 '13 at 12:28
The recursive version didn't work for me -- rename complained about the command being in an invalid format. Turns out the /s caused the second file to be listed as an absolute path and using filename expansion (%~nxf) gave me the original, uppercase filename. Ended up just manually recursing. –  Dogmatixed Aug 7 '13 at 1:21
This is a very nice answer; to the point, no external programs needed, nice and small command, no batch file complicated-ness needed. –  Jeff Wilbert Oct 10 '13 at 15:44

spacetornado Renamer is a Windows program that renames mass amounts of files in batches. You can search and replace text, remove a certain number of characters, change the case to lower, upper or First Letter Capital, and add text to the beginning or end (append/prepend) of every filename

-
Please give me the reason for down vote ? –  joe Nov 4 '09 at 8:52
People rarely explain, unfortunately :/ –  Gnoupi Nov 4 '09 at 9:02
I guess the downvote was because the OP wanted a solution that worked without any additional software. And I guess the downvote wasn't explained because some people are prone to deal out revenge downvotes. –  innaM Nov 4 '09 at 12:20
The GUI is a little funky but it does the job better than several other renamers that I've seen out there. –  jcollum Nov 23 '10 at 21:46
+1 Just what I needed. –  starblue Mar 28 '12 at 13:29

My personal favorite batch file-renaming utility is Cylog's WildRename. Among many other features, it can change the case of filenames. The best thing about WildRename is probably that it supports regular-expressions!

-

You could use a "character replacement" strategy...

set Name=%Name:A=a%
set Name=%Name:B=b%
set Name=%Name:C=c%


...and so on, for letters A-Z. You could probably implement it in the form of a FOR loop.

-

http://www.dostips.com/DtCodeCmdLib.php#Function.toLower gives a simple function that you should be able to include and call from a batch file.

So have the batch file iterate over the folders/filenames, and call this function to generate the lowercase version of the name.

-

Using only standard commands, I have scripted LwrCase.bat and LwrCase_Folder.bat, to rename a file name to lower case, or rename all file names in a folder to lower case.

To rename a file name to lower case, use:

[call] LwrCase FullyQualifiedFileName


Where FullyQualifiedFileName is the fully qualified file name to be renamed.

To rename all the files names in a directory, use:

[call] LwrCase_Folder FullyQualifiedDirectoryName [/S]


where FullyQualifiedDirectoryName is the fully qualify folder path, and /S is an optional parameter that will also rename files names in all sub-folders.

NOTE: LwrCase.bat makes use the the /L switch of the DIR command, which returns lower case names.

LwrCase.bat contains:

@echo off
if {%1}=={} @echo Syntax: LwrCase FullyQualifiedFileName&goto :EOF
setlocal
for /f "Tokens=*" %%a in ('@echo %~a1') do (
set file=%%a
)
if /i "%file:~0,1%" EQU "d" @echo LwrCase - %1 is NOT a file.&endlocal&goto :EOF
for /f "Tokens=*" %%f in ('dir %1 /L /b /a /a-d') do (
Rename %1 "%%f"
)
endlocal


LwrCase_Folder.bat contains:

@echo off
if {%1}=={} @echo Syntax: LwrCase_Folder FullyQualifiedDirectoryName&goto :EOF
setlocal
for /f "Tokens=*" %%a in ('@echo %~a1') do (
set folder=%%a
)
if /i "%folder:~0,1%" NEQ "d" @echo LwrCase_Folder - %1 is NOT a folder.&endlocal&goto :EOF
pushd %1
set sw=/B /A /A-D
if /i {%2}=={/S} set sw=%sw% %2
for /f "Tokens=*" %%f in ('dir %sw%') do (
call LwrCase "%%f"
)
popd
endlocal

-

When you say 'only windows (XP or 7), does this exclude using Python?

Something as simple as http://www.palovick.com/code/python/python-rename-files.php will handle it.

in this post.

I can't vouch for this but it may be what you are looking for.

-

The best program for doing this in Windows is Bulk Rename Utility. It is a mans tool. You can even use regex to rename files and/or folders. It also has shell integration (so you can execute from explorer with a right click) which is very nice. 64 bit and 32 bit versions available.

-

Recursive solution. Put this into a recursiverename.cmd file..

for /f "Tokens=*" %%f in ('dir /l/b/a-d') do (rename "%%f" "%%f")
for /r /d %%x in (*) do (
pushd "%%x"
for /f "Tokens=*" %%f in ('dir /l/b/a-d') do (rename "%%f" "%%f")
popd
)

-

Since Windows 7 you could use PowerShell for those tasks

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


- folder names are excluded with Where {-Not \$_.PSIsContainer} |