Hey I need help cleaning up my script.
Is it in the right forum btw????
Is it in the right forum btw????
Code:
Function FolderDlg
Const MY_COMPUTER = &H11&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder (WINDOW_HANDLE, "Select a folder:", OPTIONS, strPath)
If objFolder Is Nothing Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
FolderDlg = objPath
End Function
Function WeighFolder (ByVal strFolder)
Dim objFSO
Dim ParentFld
Dim ParentSz
Set objFSO = CreateObject("scripting.FileSystemObject")
Set ParentFld = objFSO.GetFolder (strFolder)
ParentSz = Round (ParentFld.Size /1024/1024,2) & " MB"
WeighFolder = ParentSz
End Function
Function CountFiles (ByVal strFolder)
Dim objFSO
Dim ParentFld
Dim SubFld
Dim IntCount
Set objFSO = CreateObject("scripting.FileSystemObject")
Set ParentFld = objFSO.GetFolder (strFolder)
IntCount = ParentFld.Files.Count
For Each SubFld In ParentFld.SubFolders
IntCount = IntCount + CountFiles(SubFld.Path)
Next
CountFiles = IntCount
End Function
RenameSubfolders (FolderDlg)
Function RenameSubfolders (ByVal strFolder)
Dim objFSO
Dim ParentFldr
Dim SubFldrs
Dim SubFldr
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ParentFldr = objFSO.GetFolder(strFolder)
Set SubFldrs = ParentFldr.Subfolders
For Each SubFldr in SubFldrs
SubFldr.Name = SubFldr.Name & " [Files - " & CountFiles (SubFldr) & "; Size - " & WeighFolder (SubFldr) & "]"
Next
End Function