Editting the title of the other thread to something like Working with folders might have been a better idea than creating a new thread
Is this the official policy? Because I'd intuitively suppose that keeping subjects separate facilitates clarity, searching for titles and avoidance of cross-posting confusion. I have also noticed that some threads got very long and off-putting. But if it's how things are done here, of course I'll comply.
If someone want to use or develop this simple vbs script, which usually sends csv file from selected folder content to the current user desktop, then do it. Why is selected csv file - simply then You can see it more correctly using spredsheets (exel) table. But of course, it can be opened also using any kind of text editor. Here is two versions, the first sends file where content size is in megabytes(MB), the other in kilobytes (kB). NB! You can copy this script to Notebad and save as file.vbs using encoding "Unicode". Code 1 (Size is in MB) Spoiler Code: '========================================================================== ' NAME: folderSize.vbs ' COMMENT: Scans folder sizes of a selected folder. '========================================================================== Dim objFSO, objFolder, objFile, objFile2, F, myVar1, myVar2, folderCount, strWrite folderCount = 0 objFile2 = "folderdetails.csv" Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Call browseFolder(strFolderSrc,"Source") Set objFolder = objFSO.GetFolder(strFolderSrc) 'Write Header Row Set objFile = CreateObject("Scripting.FileSystemObject") Set strWrite = objFile.OpenTextFile(objFile2, 2, True) strWrite.WriteLine("Folder Name,Size (MB),# Files,# Sub Folders") Wscript.Sleep 300 ShowFolderDetails objFolder strWrite.Close MsgBox "Complete." Set objFSO = Nothing Set objFolder = Nothing Set objFile = Nothing Set objFile2 = Nothing Set F = Nothing Set myVar1 = Nothing Set myVar2 = Nothing Set strWrite = Nothing WScript.Quit '========================================================================== 'Functions Function ShowFolderDetails(oF) strWrite.WriteLine(oF.Name + "," + CStr(oF.Size /1024\1024) + "," + CStr(oF.Files.Count) + "," + CStr(oF.Subfolders.Count)) 'Comment out the following line and the loop to end the statement 'to list all subfolders.(End Loop is 6 lines down) Do While folderCount < 1 for each F in oF.Subfolders ShowFolderDetails F Next folderCount = folderCount + 1 Loop End Function ' browseFolder brings up the selection box to choose both the source and the destination. Function browseFolder(myVar1,myVar2) Const WINDOW_HANDLE = 0 Const NO_OPTIONS = 0 Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.BrowseForFolder _ (WINDOW_HANDLE, "Select a " & myVar2 & " folder:", NO_OPTIONS, "C:\Scripts") On Error Resume Next Set objFolderItem = objFolder.Self objPath = objFolderItem.Path myVar1 = objPath Call objPathChk(myVar1) End Function ' objPathChk checks to make sure that a source has been selected. Function objPathChk(myVar1) If myVar1 = "" Then MsgBox "Scan Folder Not Specified." & VbCrLf & _ "Scan will now quit.", vbOKOnly, "Terminate" WScript.Quit End If End Function '========================================================================== Code 2 (Size is in kB) Spoiler Code: '========================================================================== ' NAME: folderSize.vbs ' COMMENT: Scans folder sizes of a selected folder. '========================================================================== Dim objFSO, objFolder, objFile, objFile2, F, myVar1, myVar2, folderCount, strWrite folderCount = 0 objFile2 = "folderdetails.csv" Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Call browseFolder(strFolderSrc,"Source") Set objFolder = objFSO.GetFolder(strFolderSrc) 'Write Header Row Set objFile = CreateObject("Scripting.FileSystemObject") Set strWrite = objFile.OpenTextFile(objFile2, 2, True) strWrite.WriteLine("Folder Name,Size (kB),# Files,# Sub Folders") Wscript.Sleep 300 ShowFolderDetails objFolder strWrite.Close MsgBox "Complete." Set objFSO = Nothing Set objFolder = Nothing Set objFile = Nothing Set objFile2 = Nothing Set F = Nothing Set myVar1 = Nothing Set myVar2 = Nothing Set strWrite = Nothing WScript.Quit '========================================================================== 'Functions Function ShowFolderDetails(oF) strWrite.WriteLine(oF.Name + "," + CStr(oF.Size /1024) + "," + CStr(oF.Files.Count) + "," + CStr(oF.Subfolders.Count)) 'Comment out the following line and the loop to end the statement 'to list all subfolders.(End Loop is 6 lines down) Do While folderCount < 1 for each F in oF.Subfolders ShowFolderDetails F Next folderCount = folderCount + 1 Loop End Function ' browseFolder brings up the selection box to choose both the source and the destination. Function browseFolder(myVar1,myVar2) Const WINDOW_HANDLE = 0 Const NO_OPTIONS = 0 Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.BrowseForFolder _ (WINDOW_HANDLE, "Select a " & myVar2 & " folder:", NO_OPTIONS, "C:\Scripts") On Error Resume Next Set objFolderItem = objFolder.Self objPath = objFolderItem.Path myVar1 = objPath Call objPathChk(myVar1) End Function ' objPathChk checks to make sure that a source has been selected. Function objPathChk(myVar1) If myVar1 = "" Then MsgBox "Scan Folder Not Specified." & VbCrLf & _ "Scan will now quit.", vbOKOnly, "Terminate" WScript.Quit End If End Function '==========================================================================
Thanks 100 for both clarifications. T-S also has me convinced, especially since hovering the mouse over a file shows its size fast enough, while third party progs also do it, as suggested by Nucleus. And, of course, old XP had no difficulty either (here we go again). But then, Win 10 has to accommodate all those gimmicks, bells and whistles, not to mention intensive data gathering. Now, if instead of gathering data on the user it was gathering them on files and folders, it wouldn’t have trouble with showing basic info about them.
When I was new at my job, I used to include several items in a letter to someone, e.g. another company. I thought I was being efficient this way. But soon I noticed that it confused them and also they were only answering some of the points and ignored others that apparently did not suit them. So I had to send reminders and follow-up letters. Consequently, I changed policy and kept different subjects separate, using ad hoc letters, and the problem was solved. P.S. You’ll notice, I’ve used two posts to deal with the two different subjects being discussed.
Also keep in mind that there's a third way. A good alternate file manager. There are many out there and usually they are way more rich than the basic win explorer. XYexplorer or Qdir just to mention two of them