DirGetSize
From AutoIt Wiki
Returns the size in bytes of a given directory. Adapted from AutoIt docs.
Contents |
Syntax
$x = DirGetSize("path" [,flag])
Parameters
| path | The directory path to calculate. Trailing backslashes are not required. e.g. "C:\Windows". |
| flag | Determines the behavior and result of the function. |
Flag
0 Recursive mode ON (default) 1 Extended mode ON 2 Recursive mode OFF
The flags may be combined in a logically cohesive order.
Return Value
Success: Returns size of directory. Failure: Returns -1 and sets @error to 1 if the path does not exist.
Extended mode returns an array of three elements containing the following information:
[0] = size [1] = file count [2] = dir count
Example
$size = DirGetSize(@HomeDrive)
Msgbox(0,"","Size(MegaBytes):" & Round($size / 1024 / 1024))
$size = DirGetSize(@WindowsDir, 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)
EndIf