Jump to content

Search the Community

Showing results for tags 'dirgetsize'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. I'm working on a script to copy a subset of files and folders from a PC to a server. I'm using the extended info from DirGetSize to show how many files and folders and total size that will be copied (copy being done by RoboCopy). Then I run DirGetSize against the destination when the copy is done to compare against the DirGetSize from the copy source so I can know if anything got skipped. I'm finding that a lot of stuff is getting skipped. This lead me to realize that it's because DirGetSize is including files and folders that are hidden and/or system, and I'm excluding these in RoboCopy. Is there anyway to excluded these from DirGetSize? I've been unable to find a UDF as yet, and I'd like to do something a little more elegant than piping the output from DIR into a file and reading that back.
  2. Here is my _DirGetSizeEx function. It allows you to get the size of a directory, with additional filters for including, excluding files and folders. ; #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 = exclude defined folders (default = "" [none]). Only used if $iFlag = 0 or 1 ; $iFlag - [optional] 0 (default) = Returns the size ; 1 = Extended mode is On -> returns an array that contains the file of each file (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][0] = Files count ; $aArray[0][1] = Total files size ; $aArray[1][0] = Full name of 1st file ; $aArray[1][1] = Size of 1st file ; $aArray[2][0] = Full name of 2nd file ; $aArray[2][1] = Size of 2nd file ; $aArray[n][1] = Size of nth file ; $aArray[n][1] = Size of nth file ;=============================================================================================================================== 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, $iFullSize = 0 Local $aFiles[1][2] = [[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) $iFullSize += $iSize If $iExtMode Then $iCountFile += 1 If $iCountFile >= UBound($aFiles) Then Redim $aFiles[UBound($aFiles) * 2][2] $aFiles[$iCountFile][0] = $aDirs[$n] & "\" &$sFileName $aFiles[$iCountFile][1] = $iSize EndIf EndIf EndIf WEnd If NOT $iRecMode Then ExitLoop EndIf FileClose($hSearch) If $n = $iCountDir Then ExitLoop $n += 1 WEnd If NOT $iExtMode Then Return $iFullSize Redim $aFiles[$iCountFile + 1][2] $aFiles[0][0] = $iCountFile $aFiles[0][1] = $iFullSize Return $aFiles EndFunc Old functions : _DirGetSizeEx-old.au3 _DirGetSizeByExtension.au3
×
×
  • Create New...