vickerps Posted April 7, 2010 Posted April 7, 2010 Wondering if there is a way of getting the total size of a folder while providing and exception list of sub folders i don't want to be included in the final count. For example I have a folder z:\Builds. Within 'Builds' there are many sub folders however in each sub folder there is a folder called archive. I want each archive folder from each sub folder to be included in the folder size of z:\builds. Hope this make sense Can anyone help?
Moderators Melba23 Posted April 7, 2010 Moderators Posted April 7, 2010 vickerps,Search using the keywords "+recursive +search". There are many scripts out there which will list the subfolders in path. Once you have the list of subfolders, run through it and use DirGetSize on those you want to include in the total.Give it a try and come back if you run into problems. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
somdcomputerguy Posted April 7, 2010 Posted April 7, 2010 This will handle most of what you want, DirGetSize, I'm not sure how to handle an 'exception list' thing though. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
KaFu Posted April 7, 2010 Posted April 7, 2010 Try this adjusted version of my _DirGetSizeEx() UDF...expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: KaFu Script Name, Version and Date: _DirGetSizeEx v04 (09-Jan-22) http://www.autoitscript.com/forum/index.php?showtopic=88094&view=findpost&p=699650 Script Function: _DirGetSizeEx, a replacement for DirGetSize() UDF using AU native functions only. Faster than DirGetSize() in the inital run on XP, slower in a repeated run, DirGetSize seems to cache the result. Change $Path between tests to seem what I mean. DirGetSize can not be interrupted / stopped, that's the main reason I coded this UDF Function returns an array $array[0] = Bytes $array[1] = File Count $array[2] = Folder Count @error = 1, max. recursion level of 5100 exceeded, directory structure too deep On Vista DirGetSize seems to be much faster than on XP, thus if you're only into speed use something like: if @OSVersion <> "WIN_VISTA" Then $aResult = _DirGetSizeEx($Path) Else $aResult = DirGetSize($Path) EndIf But keep in mind, main advantage of _DirGetSizeEx is that during runtime you can easily implement a progress count or interrupt the function with a global variable (like I do in SMF, just define a bool something like $running = true and switch it with WM_COMMAND) #ce ---------------------------------------------------------------------------- Dim $Path = "z:\Builds" Global $dirKeyWord = "archive" $a_DirGetSizeEx = _DirGetSizeEx($Path) ; <= recommended MsgBox(0, '_DirGetSizeEx()', '' _ & '_DirGetSizeEx()' & @crlf & 'Bytes: ' & $a_DirGetSizeEx[0] & @crlf & 'File Count: ' & $a_DirGetSizeEx[1] & @CRLF & 'Folder Count: ' & $a_DirGetSizeEx[2] & @CRLF & @CRLF) Func _DirGetSizeEx($sPath = @ScriptDir) Local $sSearch, $aResult_sub[3] Local $aResult[3] = [0,0,0] if Not IsDeclared("iDirGetSizeExRecursionLevel") then Global $iDirGetSizeExRecursionLevel = 1 Else $iDirGetSizeExRecursionLevel += 1 endif if $iDirGetSizeExRecursionLevel = 5099 Then SetError(1) Return endif If StringRight($sPath, 1) <> "\" Then $sPath &= "\" ; Ensure $sPath has a trailing slash $sSearch = FileFindFirstFile($sPath & "*.*") While 1 $sNext = FileFindNextFile($sSearch) ; check if next file can be found, otherwise exit loop If @error Then ExitLoop If StringInStr(FileGetAttrib($sPath & $sNext & "\"), "D") Then if $sNext = $dirKeyWord or StringInStr($sPath & $sNext,"\" & $dirKeyWord & "\") then $aResult[2] += 1 $aResult_sub = _DirGetSizeEx($sPath & $sNext) if @error then SetError(@error) Return endif $aResult[0] += $aResult_sub[0] $aResult[1] += $aResult_sub[1] $aResult[2] += $aResult_sub[2] Else if not StringInStr($sPath & $sNext,"\" & $dirKeyWord & "\") then ContinueLoop $aResult[1] += 1 $aResult[0] += FileGetSize($sPath & $sNext) EndIf WEnd FileClose($sSearch) Return $aResult EndFunc ;==>_DirGetSizeEx OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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