6

I have a legacy directory structure from a desktop application that I'm porting to an Android application, and Android doesn't want the names of the files to have capital letters in them. I had originally decided to suck it up and rename them by hand (about a hundred files), but then I found that Windows was thwarting even those attempts: QuotationMarks.png -> quotationmarks.png doesn't even stick, because Windows is case-insensitive: it doesn't even register it is as a filename change. I'd have to QuotationMarks.png -> quotationmarks2.png -> quotationmarks.png for all files, which I would like to avoid.

So is there some kind of secret power app that will allow to perform this operation batch?

2
  • Keltari's script does the job no doubt, but I can't even begin to count the number of bulk file renamers available for Windows. Any one of them would have helped I'm sure.
    – Karan
    May 25, 2013 at 22:12
  • The key is the method of renaming. Renaming the file to all lowercase will fail in some cases, since Windows isnt case sensitive and the file already exists as that name. If you change my script to rename the file, it will fail saying the file already exists. Thats why I used the MoveFile function. However, if you had Services for Unix installed, renaming should work...
    – Keltari
    May 26, 2013 at 1:57

2 Answers 2

9

Command line:

for /F %a in ('dir /L /B') do ren %a %a

batch:

for /F %%a in ('dir /L /B') do rename %%a %%a
3
  • This works too.
    – Keltari
    May 26, 2013 at 3:02
  • This one gets the pot for conciseness. Nice job! May 28, 2013 at 16:53
  • in case the filenames have whitespace, add quotes in rename: for /F %a in ('dir /L /B') do ren "%a" "%a", see also superuser.com/questions/65302/…
    – Peter T.
    Sep 13, 2017 at 11:57
3

This VBScript will do it. Be sure to set the variable objStartFolder to the right location. Save as a .VBS and double click to run. It will rename all the files in the specified directory to all lower case.

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\Myfolder"

Set objFolder = objFSO.GetFolder(objStartFolder)

Set colFiles = objFolder.Files
For Each objFile in colFiles
    ObjFSO.MoveFile objStartFolder & "\" & ObjFile.Name, objStartFolder & "\" & lcase(ObjFile.Name)
Next

PS. Technically, I am not renaming the file, but moving it, but the results are the same. Renaming the file will fail, since the filename already exists.

3
  • Thanks! I ended up booting into Linux and writing a shell script, but you deserve recognition for your answer! Thank you! May 25, 2013 at 21:39
  • Just curious - any particular reason why you deleted the almost identical answer, then posted this one a minute later?
    – Karan
    May 25, 2013 at 22:11
  • @Karan I was editing the answer, or was attempting to, hit the backspace key which instead of deleting the character took me back a page. I ended up editing the answer there and committing the change, but it made a new answer.
    – Keltari
    May 26, 2013 at 1:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .