Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
Const folder = "C:\documents and settings\swd\my documents\testfolder" Const logfile = "logfile.log" ' === If folder = "" OR logfile = "" Then WScript.Quit End If Dim fso: Set fso = CreateObject("Scripting.FileSystemObject") Set objfolder = fso.GetFolder(folder) If fso.FileExists(folder & "\" & logfile) Then fso.DeleteFile(folder & "\" & logfile) End If Set objlog = fso.CreateTextFile(folder & "\" & logfile, true) Call LoopFolder(objfolder) Sub LoopFolder(folderobj) Set objfiles = folderobj.files Set objsubfolders = folderobj.subfolders for each subfolder in objsubfolders Call LoopFolder(subfolder) next i = 1 for each file in objfiles if not file.Name = logfile Then objlog.WriteLine("[" & Now() & "] Renaming File " & file.Name & " to " & folderobj.Path & "\" & folderobj.Name & i & "." & fso.GetExtensionName(file.Name)) file.Move folderobj.Path & "\" & folderobj.Name & i & "." & fso.GetExtensionName(file.Name) End If i = i+1 next End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.