[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Display in one window, instead of several

Posted on 2006-07-10
9
Medium Priority
?
208 Views
Last Modified: 2010-04-17
The script below displays the size of immediate sub-directories within c:\documents and settings. How may I cause it to display in one windows, instead of one-each for each result?

Dim objFSO, objFolder, objSub, nTotal
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("c:\documents and settings")

nTotal = 0
'loop through each subfolder, displaying its size
For Each objSub In objFolder.SubFolders
      Wscript.Echo "Folder " & objSub.Name & " is " & ((objSub.Size)/1048576) _
      & " MB"
      ntotal = nTotal + ((objSub.Size)/1048576)
Next

Wscript.Echo "Total for all folders:" & nTotal & " MB"
0
Comment
Question by:johndarby
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 17075983
Hmm, I wonder if a for instead of a foreach work...
0
 
LVL 15

Accepted Solution

by:
bpmurray earned 2000 total points
ID: 17076096
Try this:

nTotal = 0
'loop through each subfolder, displaying its size
Dim displayText
displayText = ""
For Each objSub In objFolder.SubFolders
     'Wscript.Echo "Folder " & objSub.Name & " is " & ((objSub.Size)/1048576) & " MB"
     displayText = displayText & Chr(10) & "Folder " & objSub.Name & " is " & ((objSub.Size)/1048576) & " MB"
     ntotal = nTotal + ((objSub.Size)/1048576)
Next

Wscript.Echo displayText & Chr(10) & Chr(10) & "Total for all folders:" & nTotal & " MB"
0
 
LVL 1

Author Comment

by:johndarby
ID: 17076413
Works like a charm...thank you!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:johndarby
ID: 17076468
How do I truncate the numeric results to two decimal places?
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17076972
Use FormatNumber ...
& " is " & FormatNumber((objSub.Size)/1048576, 2) & " MB"   ' 2 = number of decimals
0
 
LVL 1

Author Comment

by:johndarby
ID: 17077117
That works wonderfully, as well!
I am going to create another issue to ask how to make a simple user interface to allow a user to enter a hostname and sharename\path to extend the function of this script.
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17077165
Actually, I've never done any major dialog stuff, so I don't know if you can do it in one dialog, but this will certainly work:
  Dim Host, Share
  Host = InputBox("Enter host name")
  Share= InputBox("Enter share name & path")

0
 
LVL 1

Author Comment

by:johndarby
ID: 17077220
Thanks bpmurray! I am unsre how exactly to add these, but I am working on it now!
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17077246
Have fun! Glad I could help.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Progress

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question