neogia Posted April 19, 2006 Posted April 19, 2006 (edited) MsgBox(0,"", _GetFolderSize("C:\WINDOWS", "mb")) Func _GetFolderSize($dir, $units = "b") $obj = ObjCreate("Scripting.FileSystemObject") If @error == 0 Then $folder = $obj.GetFolder($dir) Select Case $units == "b" Return $folder.Size Case $units == "kb" Return $folder.Size/1024 Case $units == "mb" Return $folder.Size/1024/1024 Case $units == "gb" Return $folder.Size/1024/1024/1024 Case $units == "tb" Return $folder.Size/1024/1024/1024/1024 EndSelect Else MsgBox(0,"","An error occurred, check that " & $dir & " exists.") EndIf EndFunc Edited April 19, 2006 by neogia [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia
randallc Posted April 19, 2006 Posted April 19, 2006 Hi, Thanks! Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
elgabionline Posted April 19, 2006 Posted April 19, 2006 Func _GetFolderSize($dir, $units = "b") At your way, but this makes the same thing that DirGetSize, that comes in-built with Autoit. Anyway, interesting use of object.
neogia Posted April 19, 2006 Author Posted April 19, 2006 Interesting. There was a post in Support, and a couple others were trying to find a way to do it, and I just assumed that function didn't exist in AutoIt. Just goes to show you what happens when you assume.... sometimes your wrong. [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia
elgabionline Posted April 19, 2006 Posted April 19, 2006 Interesting. There was a post in Support, and a couple others were trying to find a way to do it, and I just assumed that function didn't exist in AutoIt. Just goes to show you what happens when you assume....sometimes your wrong.Most of those asked in support, but mostly are responded in the read help of AutoIt. Anyway, interesting...
slightly_abnormal Posted April 20, 2006 Posted April 20, 2006 (edited) i think the built in one only gets the size in megabytes... but i could be wrong. i like it. Edited April 20, 2006 by slightly_abnormal
Moderators SmOke_N Posted April 20, 2006 Moderators Posted April 20, 2006 (edited) i think the built in one only gets the size in megabytes... but i could be wrong. i like it.$size = DirGetSize("C:") Msgbox(0,"","Size(MegaBytes):" & Round($size / 1024 / 1024)) $size = DirGetSize("C:\Windows", 2) Msgbox(0,"","Size(MegaBytes):" & Round($size / 1024 / 1024)) $timer = TimerInit() $size = DirGetSize("\\10.0.0.1\h$",1) $diff = Round(TimerDiff($timer) / 1000) ; time in seconds If IsArray($size) Then Msgbox(0,"DirGetSize-Info","Size(Bytes):" & $size[0] & @LF _ & "Files:" & $size[1] & @LF & "Dirs:" & $size[2] & @LF _ & "TimeDiff(Sec):" & $diff) EndIfIt doesn't say specifically that it returns in bytes but... the Size(MegaBytes):" & Round($size / 1024 / 1024) gives it away . Edited April 20, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now