Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Basic Script .vbs - uses Browse Dialog to rename subfolders in parent folder...

Status
Not open for further replies.

Aramaic

Technical User
Aug 17, 2013
4
ZA
Hey I need help cleaning up my script.
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
 
Yo what's up?!
No one helping me haha.
That sucks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top