#157819 - 2006-02-24 01:59 PM
fnGetFileProp Size in MB's
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
I'm writing a script to scan the size of our exchange DB. While GetFileSize doesn't support file greater than 2Gb, I'm using the UDF fnGetFileProp to retrieve it's size. This works fine, but the results are in bytes. This gives me a numer in the format of 1.000.000.000. I want to retrieve the size of the DB in MB's, like 1.000
*********************** Function fnGetFileProp($sFile,$sProp) Dim $objFSO, $objFile, $nul $objFSO = CreateObject("Scripting.FileSystemObject") If Not VarType($objFSO)=9 Exit 1 EndIf $objFile = $objFSO.GetFile($sFile) If Not VarType($objFile)=9 Exit 2 EndIf $nul=Execute("$$fnGetFileProp = $$objFile."+$sProp) If VarType($fnGetFileProp)=0 Exit 87 EndIf EndFunction
$Priv1EDB = "\\server\mdbdata\Priv1.edb"
$PrivResult = FormatNumber(fnGetFileProp($Priv1EDB,Size),0) ?
*******************************
Can anyone help me ?
|
|
Top
|
|
|
|
#157821 - 2006-02-24 02:03 PM
Re: fnGetFileProp Size in MB's
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
Yeah, I know. But were do I put this in my script ?
|
|
Top
|
|
|
|
#157822 - 2006-02-24 02:10 PM
Re: fnGetFileProp Size in MB's
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
How about here: Code:
$PrivResult = FormatNumber(CDbl(fnGetFileProp($Priv1EDB,Size))/(1024*1024),0) ?
|
|
Top
|
|
|
|
#157823 - 2006-02-24 02:14 PM
Re: fnGetFileProp Size in MB's
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
Your'e the best. Thanx a lot, that works perfect for me !
|
|
Top
|
|
|
|
#157824 - 2006-02-24 02:49 PM
Re: fnGetFileProp Size in MB's
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
Do you know how to put 2 results together ? Say I want to add the size of the .STM to the size of the .EDB into a new variable:
--------- $Priv1EDBResult = FormatNumber(CDbl(fnGetFileProp($Priv1EDB,Size))/(1024*1024),0) ? $Priv1STMResult = FormatNumber(CDbl(fnGetFileProp($Priv1STM,Size))/(1024*1024),0) ? $Priv1 = $Priv1EDBResult + $Priv1STMResult ------------
$Priv1 does not give the right results. How do I have to add these two ?
|
|
Top
|
|
|
|
#157825 - 2006-02-24 03:23 PM
Re: fnGetFileProp Size in MB's
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
FormatNumber() converts the number to a string, so the expression concatenates the numbers instead of adding them together.
If you leave out the formatting the variables will remain numeric and the addition will work as you expect.
Code:
$Priv1EDBResult = CDbl(fnGetFileProp($Priv1EDB,Size))/(1024*1024) $Priv1STMResult = CDbl(fnGetFileProp($Priv1STM,Size))/(1024*1024) $Priv1 = $Priv1EDBResult + $Priv1STMResult
|
|
Top
|
|
|
|
#157826 - 2006-02-24 04:10 PM
Re: fnGetFileProp Size in MB's
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
YES, that's it ! My last line for $Priv1 = I formatted like this:
$Priv1 = FormatNumber(CDbl($Priv1EDBResult + $Priv1STMResult),0) ?
This gives me the result of x.xxx MB for the total of the 2 databases.
Thanx a lot for your help !
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 484 anonymous users online.
|
|
|