PROBLEMCHYLD Posted April 10, 2011 Share Posted April 10, 2011 I am using a VBS script called Change File Name Case from this site.http://www.ericphelps.com/scripting/samples/index.htmIf its possible, I would like the script to do multiple subfolders instead of just one at a time.Can someone help me? Link to comment Share on other sites More sharing options...
Yzöwl Posted April 10, 2011 Share Posted April 10, 2011 Do you mean that instead of using this, you'd prefer something a little more like this? Link to comment Share on other sites More sharing options...
PROBLEMCHYLD Posted April 10, 2011 Author Share Posted April 10, 2011 Do you mean that instead of using this, you'd prefer something a little more like this?yes but I would like everything uppercase. thanks I definitely missed that. Link to comment Share on other sites More sharing options...
allen2 Posted April 10, 2011 Share Posted April 10, 2011 I'd just replace the 6 Lcase with 6 Ucase. Link to comment Share on other sites More sharing options...
PROBLEMCHYLD Posted April 10, 2011 Author Share Posted April 10, 2011 Thanks got it working. Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 10, 2011 Share Posted April 10, 2011 Here is a script I wrote up it does1:\ Runs in Cscript2:\ Can have Manual Input3:\ Drag And Drop Folder4:\ uses Wmi to rename files5:\ Save ResultsOption Explicit'-> ObjectsDim Act :Set Act = CreateObject("Wscript.Shell")Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Wmi :Set Wmi = GetObject("winmgmts:{impersonationLevel=" & _ "impersonate}!\\.\root\cimv2") '-> Varibles Dim A1, Arg, C1, Col, errResult, File, LDim Name, Obj, Path, Rpt, Str, T, Ts, ZA1 = Chr(160) & Chr(187) & Chr(160) L = "----------------------------------------------------"'-> Make Sure Correct Engine Cscript Is Active If InStr(1,WScript.FullName,"cscript",1) Then UserInput() ElseIf InStr(1,WScript.FullName,"wscript",1) Then T = Space(14) & A1 & "ERROR : Wrong Scripting Engine" T = T & vbCrLf T = T & "This Script Was Ment To Be Run From The Cscript Engine." T = T & vbCrLf T = T & "Right Click The Script, Select The Cmd Prompt To Open It" Msgbox T,4128,"Error Wrong Script Engine" WScript.Quit End If'-> Get The Folder Path Either Drag Drop Or Manual Input. Function UserInput() Do While Str = "" WScript.StdOut.WriteLine L WScript.StdOut.WriteLine "This script was ment to rename all the Files in a" WScript.StdOut.WriteLine "Folder,and all sub folder to lowercase lettering" WScript.StdOut.WriteLine " 1:\ Type in the Full Path to the Folder" WScript.StdOut.WriteLine " 2:\ Drag And Drop Folder On This Window" WScript.StdOut.WriteLine " 3:\ Press Enter To Continue Script" WScript.StdOut.WriteLine " 4:\ Type Exit Or Quit To Do Nothing" WScript.StdOut.WriteLine L & vbCrLf If Wscript.Arguments.Count = 1 Then For Each Arg In WScript.Arguments'-> Separate Files From Folders After Drag And Drop If Right(InStr(Arg,"."),3) Or _ Right(InStr(Arg,"."),4) Or _ Right(InStr(Arg,"."),5) Then Else Str = Arg End If Next End If Str = Wscript.StdIn.ReadLine If InStr(1,Str,"Exit",1) Or InStr(1,Str,"quit",1) Then WScript.Quit If Len(Str) >= 4 And Fso.FolderExists(Str) Then WScript.StdOut.WriteLine L ReNameRecursive(Fso.GetFolder(Str)) ElseIf Len(Str) = 3 Or Len(Str) = 2 Or Len(Str) = 1 Then call MyError(_ "Error Can Not Run Scan From Root Dir","Root Drive Error : " & Str) ElseIf Not Fso.FolderExists(Str) Then call MyError( _ "This Folder Does Not Exists Error", "Missing : " & Str ) End If Loop End Function'-> Function To Output Error Messages Function MyError(A,B) WScript.StdOut.WriteBlankLines 3 WScript.StdOut.WriteLine A WScript.StdOut.WriteLine B WScript.StdOut.WriteLine "Reloading User Input" WScript.Sleep 3000 WScript.StdOut.WriteBlankLines 3 Str = "" UserInput() End Function'-> Rename All Files In Parent Folder And All Sub Function ReNameRecursive(Folder) Set File = Wmi.ExecQuery("ASSOCIATORS OF " & _ "{Win32_Directory.Name='" & Folder &"'} " & _ "Where ResultClass = CIM_DataFile") C1 = C1 + File.Count For Each Obj In File WScript.StdOut.WriteLine _ "Processing" & A1 & Obj.FileName & vbCrLf & L Path = Obj.Drive & Obj.Path Name = Obj.FileName & "." & Obj.Extension Rpt = Rpt & vbCrLf & _ "Old" & A1 & Path & "\" & Name & vbCrLf & _ "New" & A1 & Path & LCase(Name) & vbCrLf & L errResult = Obj.Rename(Path & "\" & LCase(Name)) Next For Each Col In Folder.SubFolders ReNameRecursive(Col) Next End Function'-> Save The Scan Results Function SaveResults() Dim Txt :Txt = Act.SpecialFolders("Desktop") & _ "\Rename_Results.txt" Set Ts = Fso.CreateTextFile(Txt) Ts.WriteLine "Scan Date Time" & A1 & Date & A1 & Time Ts.WriteLine "Total Number Changed" & A1 & C1 Ts.WriteLine L & vbCrLf & Rpt Ts.Close Act.Run("Notepad " & Chr(34) & Txt & Chr(34)),1,False WScript.Quit End Function'-> End Of Rename Do While Z = "" WScript.StdOut.WriteLine "Would you like to save the Results Of Rename To" WScript.StdOut.WriteLine "Lowercase File Names to a text file?" WScript.StdOut.WriteLine A1 & "1:\ Type Yes To Save Rename Results" WScript.StdOut.WriteLine A1 & "2:\ Type No To Close Window And" WScript.StdOut.WriteLine "To Not Save The Rename Results." Z = Wscript.StdIn.ReadLine If InStr(1,Z,"yes",1) Then SaveResults() If InStr(1,Z,"no",1) Then WScript.Quit LoopRename ReNameToLowerCase.vbs.txt to ReNameToLowerCase.vbs to make activeReNameToLowerCase.vbs.txt Link to comment Share on other sites More sharing options...
PROBLEMCHYLD Posted April 10, 2011 Author Share Posted April 10, 2011 Thanks, but how do you make everything upper case with your script gunsmokingman? Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 10, 2011 Share Posted April 10, 2011 Thanks, but how do you make everything upper case with your script gunsmokingman?Change this Line errResult = Obj.Rename(Path & "\" & LCase(Name))To This To Make UppercaseerrResult = Obj.Rename(Path & "\" & UCase(Name)) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now