Is there a simple way, in vbscript, to determine the total space occupied by
a directory and its subdirectories, or am I going to have to recurse through
it and add up all the file sizes?

--

Michael A. Covington - Artificial Intelligence Ctr - University of Georgia

"In the core C# language it is simply not possible to have an uninitialized
variable, a 'dangling' pointer, or an expression that indexes an array
beyond its bounds. Whole categories of bugs that routinely plague C and C++
programs are thus eliminated." - A. Hejlsberg, The C# Programming Language

Re: Total size of a directory? by Michael

Michael
Wed Apr 28 16:55:44 CDT 2004


"Michael A. Covington" <look@www.covingtoninnovations.com.for.address> wrote
in message news:%231ip5rWLEHA.3012@tk2msftngp13.phx.gbl...
> Is there a simple way, in vbscript, to determine the total space occupied
by
> a directory and its subdirectories, or am I going to have to recurse
through
> it and add up all the file sizes?

Got it from powerasp.com. They say to do this:

Set MyFileSize = Server.CreateObject ("Scripting.FileSystemObject")
MyPath = Server.MapPath("/somedirectory")
Set MyFolder = MyFileSize.GetFolder(MyPath)

Couldn't have been easier!



Re: Total size of a directory? by Fosco

Fosco
Thu Apr 29 00:08:45 CDT 2004

"Michael A. Covington"
> Is there a simple way, in vbscript, to determine the total space
> occupied by a directory and its subdirectories [...]

set fso = createobject("scripting.filesystemobject")
Set filetxt = fso.CreateTextFile("c:\Size", True)
set folder = fso.getfolder("c:\windows")
for each subfolder in folder.subfolders
t = subfolder.Size/1024000
S = formatnumber(t,,,,0) & " MB "
' wscript.echo subfolder.path
' wscript.echo "dimensione in bytes ===>", subfolder.size
filetxt.WriteLine subfolder.path
filetxt.WriteLine S
next

--
Fosco




Re: Total size of a directory? by Viatcheslav

Viatcheslav
Thu Apr 29 00:16:26 CDT 2004

> t = subfolder.Size/1024000

Should be:
t = subfolder.Size/(1024*1024)

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Fosco" <fake@fake.invalid> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:x50kc.117297$hc5.5116781@news3.tin.it...
> "Michael A. Covington"
> > Is there a simple way, in vbscript, to determine the total space
> > occupied by a directory and its subdirectories [...]
>
> set fso = createobject("scripting.filesystemobject")
> Set filetxt = fso.CreateTextFile("c:\Size", True)
> set folder = fso.getfolder("c:\windows")
> for each subfolder in folder.subfolders
> t = subfolder.Size/1024000
> S = formatnumber(t,,,,0) & " MB "
> ' wscript.echo subfolder.path
> ' wscript.echo "dimensione in bytes ===>", subfolder.size
> filetxt.WriteLine subfolder.path
> filetxt.WriteLine S
> next
>
> --
> Fosco
>
>
>