Main

Sub Main()
Dim strFilePath 'As String
Dim intUcase 'As Integer
Dim fs 'As Scripting.FileSystemObject
Dim fils 'As Scripting.Files
Dim fil 'As Scripting.File
	If MsgBox ("This program will change the case (to upper or lower case as you prefer) of all file names in a directory you designate. Continue?", vbOkCancel) = vbCancel Then Wscript.Quit
	Set fs = Wscript.CreateObject("Scripting.FileSystemObject")
	strFilePath = InputBox("Enter path to files", "Enter Path", fs.GetAbsolutePathName(fs.BuildPath(Wscript.ScriptFullName, "\..")))
	If strFilePath = "" Then Wscript.Quit
	intUcase = MsgBox("Convert all file names to UPPER case? (Yes=UpperCase, No=LowerCase)", vbYesNoCancel)
	If intUcase = vbCancel then Wscript.Quit
	Set fils = fs.GetFolder(strFilePath).Files
	For Each fil In fils
		If intUcase = vbYes Then UcaseFile fil Else LcaseFile fil
	Next
End Sub

Sub LcaseFile(objScriptingFile)
'A change to lowercase isn't recognized as a change, so we change to something else first.
Dim sFileName 'As String
	sFileName = Lcase(objScriptingFile.Name)
	objScriptingFile.Name = "-" & sFileName
	objScriptingFile.Name = sFileName
End Sub

Sub UcaseFile(objScriptingFile)
'All uppercase is generally not respected by the OS, so leave the extension lowercase
Dim sFileName 'As String
Dim nDotLocation 'As Integer
	sFileName = Ucase(objScriptingFile.Name)
	For nDotLocation = Len(sFileName) to 1 Step -1
		If Mid(sFileName,nDotLocation,1) = "." Then Exit For
	Next
	If nDotLocation = 0 Then nDotLocation = Len(sFileName) - 1
	sFileName = Left(sFileName,nDotLocation) & Lcase(Mid(sFileName,nDotLocation + 1))
	objScriptingFile.Name = "-" & sFileName
	objScriptingFile.Name = sFileName
End Sub

