Converting file extensions to lower case

Recently I needed to convert a large number of photo file extensions to lower case. Doing this manually would take ages and wouldn’t be a fun job.

I wrote a quick batch file to look through all the sub-directories from the one it is executed from and change selected file extensions to lower case.

To use this script place the below code in a file called lowerCaseExtensions.bat. Put the batch file in the directory containing the files that you want changed and double click on it.

The script will loop through all the files in the directory, and will loop thought the files in all sub-directories and will change jpg, png and gif extension to lower case.

@echo off
pushd .

goto :skip_functions

	cd %1
	echo Processing %1
	ren *.JPG *.jpg 2>&1
	ren *.PNG *.png 2>&1
	ren *.GIF *.gif 2>&1
goto :EOF


for /f %%i in ('dir /b/s/ad') do call :toLower %%i


You can easily customise this to change the file extensions of other file types to lower case.

This has been tested only on my Windows XP computer so I’d suggest you test it first on some copied files before you let it lose on your real ones.

Even if you aren’t specifically interested in the functionality that this batch file implements you might find it interesting to see how to implement a simple callable function in a batch file (:toLower), and how to implement ‘for’ loops.

5 Comments on “Converting file extensions to lower case”

  1. That’s good batch script. But you can achieve a more generalized and easy solution if you create VB Script file and since windows by default has cscript command line interpreter to execute vb scripts, you can easily call it from command line.

  2. Harsh – Dude. (Cool name by the way…) Thanks for the suggestion for using VB script, but maybe you could go that extra little step and point us to a sample vb script that would change the case of files names and their extensions.

    That would be really helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *

Do NOT fill this !