Jump to content

Getting The Used Disk Space of a Drive..?


 Share

Recommended Posts

I see there are functions to get Either "DriveSpaceTotal" & "DriveSpaceFree" but is there a Function to get the "DriveSpaceUsed"..??

To return the Amount of MB a Drive is currently using..??

Or would I have to do some Function math to return this "DriveSpaceUsed" Value..??

Something like:

$Total = DriveSpaceTotal( "c:\" )
$Free = DriveSpaceFree( "c:\" )
$Used = $Total - $Free
MsgBox(0, "", "C:\ Is Using " & $Used & " MB")
Link to comment
Share on other sites

So there is no already existing AutoIt Function then for "DriveSpaceUsed"..??

If they already have the other 2 functions why not include the 3rd For "DriveSpaceUsed" so you don't have to use more code to determine this "DriveSpaceUsed" Value..??

Because it's completely unnecessary, if all function were added that was just a simple combination of two other function the function list would skyrocket.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

  • 11 months later...

Yes, but takes a lonnnnnnnnng time on a drive with lots of files.

Well, the drive that I'm trying to use this on is small. It's an email folder and I just would like easy way to monitor how much email is on in terms of total size. However, this is the only message that came up in a search, so hoping it's okay to add to this old thread.

I modified another script I have, a disk free one, with the DirGetSize option and I got this:

$var1       = DirGetSize(@ScriptDir)
$SpaceUsed  = Round($var1/1024/1000)


MsgBox(64,"Used space ...","The used space in this root folder totals at or below:" & @CRLF & _
            "----------------------------------------------------------------     " & @CRLF & @CRLF & _
            $SpaceUsed & " MB")
I get an end result here of 19 MB. But I was wondering if this was the correct way to show the total size being used up by total folder contents?

Thanks. :)

Link to comment
Share on other sites

Worked on the script some more:

;----------------------------------------------------------------
Local $sFile = @ScriptDir
; Drive letter -   Example returns     "C"
Local $sDrive = StringRegExpReplace($sFile, ":.*$", "")
;----------------------------------------------------------------
$var1       = DirGetSize(@ScriptDir)
$SpaceUsed  = Round($var1/1024/1000, 2)
;---------------------------------------
$var2       = DriveSpaceFree($Folder1LevelUp)
$SpaceFree  = Round($var2/1024, 2)
;---------------------------------------

MsgBox(64,"Used space ...","The used space in this root folder totals:" & @CRLF & _
            "---------------------------------------------------------------------" & @CRLF & @CRLF & _
            $SpaceUsed & " MB." & @CRLF & @CRLF & _
            "---------------------------------------------------------------------" & @CRLF & @CRLF & _
            $SpaceFree & " GB   is/are still free to use for the entire  [" & $sDrive & ":\]  drive.          ")

Exit    ; finished
This seems to do the job but it fails in one area, I've put MB and GB in because that's what I happen to have. It would be neat for AI to determine the size in question. But this seems to work fine, so I'll just have to remember to modify this script if sizes I'm dealing with change from MB to GB at some point down the road or if I ever were dealing with a flash drive where the total size might just be MB instead of GB in any given folder.

Edited by Diana (Cda)
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...