Batch file for renaming file extension to lowercase.

aimeeandbeatles

watermelon
Joined
Apr 5, 2007
Messages
20,112
Problem: I'm on a Windows machine. The webhost I've picked is in Unix. Anyways, some of my filename extensions (for the files meant for upload) are in uppercase... It depends on what programs I use to process them. I want them all in lowercase, but it's a pain to manually change them.

Solution (somewhat): Make a batch file that can do that.

Problem #2: I screwed it up, as usual. :lol: I'm glad it was a test folder.

Question: Does someone have one that actually works? :)

Thanks
 
The problem with that is that I dont think it would understand the case-sensitive thing
 
Are all the extensions the same? You can just do "ren *.TXT *.txt" and it will lower case them. Do it for all the file extensions you want.

EDIT: If you have a crapload of different filenames, you can do something using Excel. In command prompt, cd to the required directory, then dump the filenames of all files in that directory into a text file by typing the following:
dir /b >> dump.txt
Now open the dump.txt file, and copy all the filenames into Excel.
(In excel, the filenames should be in column A.)
In column B, type =right(A1,3)
This will give you the file extension.
In column C, type =lower(b1)
This will make the extensions lower case
Now you need to grab the filename from column A.
In column D, type =LEFT(A1,LEN(A1)-3)
Now put the two things together:
In column E, type =D1&C1
Now make a DOS command for you to put into a batch file:
In column F, type ="ren "&A1&" "&E1
Copy all those formulas all the way down the columns, so that you have a "ren" command for each file.
Now copy column F into a text file, save the text file as "lowerextensions.bat" in your preferred directory, then run the batch file.

Simple!
 
Of course it would help if I have excel. :P

But Im not working with a lot of different file extensions.... I think for the site theres a total of 3-4 types, and the odd ones (there's a number of djvu files and the odd tif or jp2 file) aren't meant for the site anyways.
 
If I put it all in one batch file will it mix up the extensions?
 
"ren *.TXT *.txt" will rename anything that ends with .TXT. So no, it won't mess any other extensions up.

It shoud look something like this:

ren *.TXT *.txt
ren *.JPG *.jpg
ren *.PDF *.pdf

and so on. Then just run the batch file and it will rename them all.
 
Back
Top Bottom