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.

Use _FO_CorrectMask, to correct the errors that can be tolerated by the user when creating a mask.
In the GUI as a separator in the mask, you can use a different character, such as ";" or "," especially when using $iTypeMask=2, but in the function parameter to replace it with a "|". You can use the Opt("GUIDataSeparatorChar", Chr(1)), to set a separator for a Combo in the GUI.
Cannot create the directory depth of more than 125.

Related

_FO_CorrectMask, _FO_FileSearch

Example

; 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)
;=======================================