Local $aSize = _DirGetSizeEx(@SystemDir, "*.exe;*.dll", 1) ConsoleWrite("Size :" & $aSize[0] & @CRLF) ConsoleWrite("Files count :" & $aSize[1] & @CRLF) ConsoleWrite("Folders count :" & $aSize[2] & @CRLF) ; #FUNCTION#==================================================================================================================== ; Name ..........: _DirGetSizeEx ; Description ...: Returns the size in bytes of a file list by extension. ; Syntax ........: _DirGetSizeEx($sDir[, $sMask = "*"[, $iFlag = 0]]) ; Parameters ....: $sDir - The directory to search in. ; $sMask - [optional] Filter for results. Default is "*" (all). ; Filter for result. Multiple filters must be separated by ";" ; Use "|" to separate 3 possible sets of filters: "Include|Exclude|Exclude_Folders" ; Include = Files/Folders to include (default = "*" [all]) ; Exclude = Files/Folders to exclude (default = "" [none]) ; Exclude_Folders = only used if $iRecur = 1 AND $iReturn <> 2 to exclude defined folders (default = "" [none]) ; $iFlag - [optional] 0 (default) = Returns the size ; 1 = Extended mode is On -> returns an array that contains extended information (see Remarks). ; 2 = Don't get the size of files in subdirectories (recursive mode is Off) ; Return values .: Success = The size in bytes, or a single dimension array ; Failure = -1 and sets the @error flag to 1 if the path doesn't exist. ; Author ........: jguinch ; Remarks .......: If you use the extended mode then the array returned from this function is a single dimension array containing the followingelements: ; $aArray[0] = Size ; $aArray[1] = Files count ; $aArray[2] = Dirs Count ;=============================================================================================================================== Func _DirGetSizeEx($sDir, $sMask = "*", $iFlag = 0); OK If NOT FileExists($sDir) Then Return SetError(1, 0, -1) If NOT StringInStr(FileGetAttrib($sDir), "D") Then Return SetError(1, 0, -1) Local $iExtMode = BitAND($iFlag, 1) > 0 Local $iRecMode = NOT BitAND($iFlag, 2) > 0 Local $aDirs[1] = [ StringRegExpReplace($sDir, "\\$", "") ] Local $iCountDir = 0, $iCountFile = 0, $n = 0, $iSize = 0 Local $hSearch, $sFileName, $sRegexFilesInclude, $sRegexFilesExclude = "^$", $sRegexFoldersExclude = "^$" Local $sRegexMask = StringReplace( StringReplace( StringReplace($sMask, "|", "\|") , "?", "\E(?:.|.?$)\Q"), "*", "\E.*?\Q") Local $aFilters = StringSplit($sRegexMask, "\|", 3) $sRegexFilesInclude = "(?i)^(?:" & StringRegExpReplace(StringReplace($aFilters[0], ";", "|") , "([^|]+)", "\\Q$1\\E") & ")$" If UBound($aFilters) > 1 Then $sRegexFilesExclude = "(?i)^(?:" & StringRegExpReplace(StringReplace($aFilters[1], ";", "|") , "([^|]+)", "\\Q$1\\E") & ")$" If UBound($aFilters) > 2 Then $sRegexFoldersExclude = "(?i)^(?:" & StringRegExpReplace(StringReplace($aFilters[2], ";", "|") , "([^|]+)", "\\Q$1\\E") & ")$" While 1 $hSearch = FileFindFirstFile( $aDirs[$n] & "\*.*" ) If $hSearch <> -1 Then While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop If @Extended Then If NOT StringRegExp($sFileName, $sRegexFoldersExclude) Then $iCountDir += 1 If $iCountDir >= UBound($aDirs) Then Redim $aDirs[UBound($aDirs) * 2] $aDirs[$iCountDir] = $aDirs[$n] & "\" & $sFileName EndIf Else If StringRegExp($sFileName, $sRegexFilesInclude) AND NOT StringRegExp($sFileName, $sRegexFilesExclude) Then $iSize += FileGetSize($aDirs[$n] & "\" &$sFileName) $iCountFile += 1 EndIf EndIf WEnd If NOT $iRecMode Then ExitLoop EndIf FileClose($hSearch) If $n = $iCountDir Then ExitLoop $n += 1 WEnd If NOT $iExtMode Then Return $iSize Local $aResult[3] = [ $iSize, $iCountFile, $iCountDir ] Return $aResult EndFunc