Jump to content
Sign in to follow this  
Diana (Cda)

DriveSpaceFree or DriveSpaceTotal ...

Recommended Posts

Diana (Cda)

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. ;)

Share this post

Link to post
Share on other sites

$Drive01Scan = "(Drive " & $Drive01 & " / TotalSpace: " & Floor(DriveSpaceTotal($Drive01)/1024) & " GB)"

When the words fail... music speaks

Share this post

Link to post
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'
    Return $size & ' B'

Edited by Zedna

Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.