Jump to content

DriveSpaceFree or DriveSpaceTotal ...


Recommended Posts

In my script, this line gives me the total disk space:

$Drive01Scan = "(Drive " & $Drive01 & " / TotalSpace: " & Floor(DriveSpaceTotal($Drive01)) & " MB)"
The measurement of MB is great if DriveSpaceFree or DriveSpaceTotal returns anything less than 1 GB. But is there a way to show measurement in GB for all DriveSpaceFree or DriveSpaceTotal results >1 GB, so that ...

<1 GB = MB

>1GB = GB?

I'd then have to change the measurement of & " MB)" in the script above somehow to reflect the right one; but one problem at a time. <g>

Thanks. ;)

Link to comment
Share on other sites

ConsoleWrite(SizeFormat(123) & @CRLF)
ConsoleWrite(SizeFormat(12345) & @CRLF)
ConsoleWrite(SizeFormat(12345678) & @CRLF)
ConsoleWrite(SizeFormat(1234567890) & @CRLF)

Func SizeFormat($size)
 If $size = '' Then Return ''
 If $size >= 1073741824 Then
    Return Round($size / 1073741824, 1) & ' GB'
 ElseIf $size >= 1048576 Then
    Return Round($size / 1048576, 1) & ' MB'
 ElseIf $size >= 1024 Then
    Return Round($size / 1024, 1) & ' kB'
 Else
    Return $size & ' B'
 EndIf
EndFunc

Edited by Zedna
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...