Function Reference
_FO_FolderSearch
Returns a list of the folders in the specified directory.
#Include <FileOperations.au3>
_FO_FolderSearch ( $sPath[, $sMask = '*' [, $fInclude=True [, $iDepth=0 [, $iFull=1 [, $iArray=1 [, $sLocale=0]]]]]] )
Parameters
$sPath | Search path |
$sMask |
[optional] The mask containing the characters "*" and "?". The character "|" is used as a delimiter. The default is '*', which means the search all directories. |
$fInclude |
[optional] Include or exclude the specified in a mask True - Find in accordance with mask (default) False - Find all except specified in a mask |
$iDepth |
[optional] The depth of nesting of directories (0 - root directory; the default 125) |
$iFull |
[optional] Paths in returned data 0 - relative 1 - Full path (by default) |
$iArray |
[optional] Specifies the output: array or list 0 - Delimited list @CRLF 1 - Array, where $iArray[0]=number of folders (by default) 2 - Array, where $iArray[0] contains the first folder |
$sLocale |
[optional] Case sensitivity. -1 - Not case sensitive (only for 'A-z'). 0 - Not case sensitive, by default. (for any characters) 1 - Case sensitive (for any characters) <ñèìâîëû> - Not case sensitive, specified range of characters from local languages. For example 'À-ÿ¨¸'. 'A-z' is not required, they are enabled by default. |
Return Value
Success: | Returns a list of folders. |
Failure: | Returns an empty string and sets @error: |
@error: | 1 - Invalid path |
2 - Invalid mask | |
3 - Not found |
Remarks
Be sure to check the @error, because in the absence of found directories, you cannot use an array. This results in an error that cannot be found in the test.Related
_FO_CorrectMask, _FO_FileSearchExample
; AZJIO
; http://www.autoitscript.com/forum/topic/133224-filesearch-foldersearch/
#include <Array.au3> ; äëÿ _ArrayDisplay
#include <FileOperations.au3>
; Folders
;=======================================
;all folders, array
$timer = TimerInit()
$FolderList = _FO_FolderSearch(@SystemDir, '', True, 125)
$timer = Round(TimerDiff($timer) / 1000, 2) & ' sec'
_ArrayDisplay($FolderList, $timer & ' - all folders')
;=======================================
; all folders, array, relative, depth=1
$timer = TimerInit()
$FolderList = _FO_FolderSearch(@SystemDir, '*', True, 1, 0)
$timer = Round(TimerDiff($timer) / 1000, 2) & ' sec'
_ArrayDisplay($FolderList, $timer & ' - all folders')
;=======================================
$timer = TimerInit()
$FolderList = _FO_FolderSearch(@UserProfileDir, '*', True, 0, 0, 0)
$timer = Round(TimerDiff($timer) / 1000, 2) & ' sec'
MsgBox(0, $timer & ' - relative ', $FolderList)
;=======================================
; Folders and files
;=======================================
$List = _FO_FolderSearch(@WindowsDir & '\Web', '*', True, 0, 0, 0) & @CRLF & _FO_FileSearch(@WindowsDir & '\Web', '*', True, 0, 0, 0)
MsgBox(0, 'folders and files', $List)
;=======================================