Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Howto: Find the Total Size of a Folder

Posted by on Sunday, January 18, 2004 (PST)

Howto: Find the total size of a folder. Uses the Scripting.FileSystemObject.

 

// Change to your folder you want the size of 
var folder = "F:\\winnt";
// Create FSO and Grab the folder you defined  
var fso = new ActiveXObject( "Scripting.FileSystemObject" );
var fl = fso.GetFolder( folder );
  
// Get the byte size of folder and sub folders. Format
// into MB as well.
var byteSize = fl.Size;
var mbSize = new String( byteSize / 1048576 ).substr( 0, 5 );
// Create display message
var msg  = "The size of " + folder + " is\n";
    msg += byteSize + " (bytes)\n";
    msg += mbSize + " MB\n";
 
// Show it
WScript.Echo(  msg  );



WSH and ADSI Administrative Scripting


Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon