Drive Space

From AutoIt Wiki
Jump to navigation Jump to search

Back to Samples

Illustrates:

  • Cheeky way of displaying a bar-chart.
    $sBar = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
    ;... in the absence of a StringRepeat("|",100)  ;o)
    $sOut = $sBar & " = 100% Capacity Baseline" & @LF
    ProgressOn("Scanning drives", "", "")
    
    $aNetDrives = DriveGetDrive( "NETWORK" )
    For $nDrv = 1 to $aNetDrives[0]
        $sDrv = StringUpper($aNetDrives[$nDrv])
        ProgressSet(100* $nDrv/$aNetDrives[0], $sDrv & " (" & $nDrv & " of " & $aNetDrives[0] & ")")
        sleep(10)
        $nSpaceFree = DriveSpaceFree($sDrv)
        $nSpaceTotal = DriveSpaceTotal($sDrv)
        $nPct = 100 * $nSpaceFree / $nSpaceTotal
        $sOut = $sOut & $sDrv & " (Free=" & StringFormat("%.2fMb",$nSpaceFree) & "; Total=" & StringFormat("%.2fMb",$nSpaceTotal) & ")" & @LF
        $sOut = $sOut & StringLeft($sBar, $nPct) & " = " & "(" & StringFormat("%.2f",$nPct) & "%)" & @LF
    Next
    
    ProgressOff()
    
    Msgbox (0,"Free Space (NETWORK)",$sOut)