Jump to content
Sign in to follow this  
cypher175

Getting The Used Disk Space of a Drive..?

Recommended Posts

cypher175

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")

Share this post


Link to post
Share on other sites
monoceres

No need for another function since it's so easy (like you already figured out) to calculate this value.

:mellow:


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

Share this post


Link to post
Share on other sites
cypher175

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..??

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
youknowwho4eva

Would a dirgetsize work?


Giggity

Share this post


Link to post
Share on other sites
ResNullius

Would a dirgetsize work?

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

Share this post


Link to post
Share on other sites
Diana (Cda)

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

Share this post


Link to post
Share on other sites
Diana (Cda)

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)

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  

×