Page 1 of 1 1
Topic Options
#161567 - 2006-05-04 10:05 PM How do I get the Size of a Directory
Templar Offline
Fresh Scripter

Registered: 2002-04-11
Posts: 41
Loc: Cincinnati
I want to get the size of an entire directory. The total size of all the files? I;ve got a utility called treeinfo but the out put ins not completely numeric. I;d like to find out the size of a directory and see if it's larger thatn 1GB if it is log it and move on.
Top
#161568 - 2006-05-04 10:49 PM Re: How do I get the Size of a Directory
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Here you go...

Code:

$Directory = "%windir%"
$DirSize = fnGetFolderProp($Directory,Size)
$DirSizeKB = $DirSize / 1024
$DirSizeMB = $DirSizeKB / 1024
$DirSizeGB = $DirSizeMB / 1024

$msg = MessageBox('The ' + $Directory + ' directory is ' + $DirSizeMB + 'MB','Notice',64)

Function fnGetFolderProp($sFldr,$sProp)
Dim $objFSO, $objFldr, $nul
$objFSO = CreateObject("Scripting.FileSystemObject")
If Not VarType($objFSO)=9 Exit 1 EndIf
$objFldr = $objFSO.GetFolder($sFldr)
If Not VarType($objFldr)=9 Exit 3 EndIf
$nul=Execute("$$fnGetFolderProp = $$objFldr."+$sProp)
If VarType($fnGetFolderProp)=0 Exit 87 EndIf
EndFunction


Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.136 seconds in which 0.102 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org