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?

  • 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 '13 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 '13 at 1:57
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
  • This works too. – Keltari May 26 '13 at 3:02
  • This one gets the pot for conciseness. Nice job! – C. Warren Dale May 28 '13 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/… – Pedi T. Sep 13 '17 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.

  • Thanks! I ended up booting into Linux and writing a shell script, but you deserve recognition for your answer! Thank you! – C. Warren Dale May 25 '13 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 '13 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 '13 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.