|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Filesystem-Commands > FIL. - File-Commands > FIL.DIR-Commands > FIL. - File and Directory Commands |
SPR Script Language
FIL.DIRS
Returns a list of Directories from a single directory path.
Intention
The FIL.DIRS command is used to get a list of directories (folders) from a specific location. It allows filtering with wildcards and can scan recursively into subdirectories. The results are stored in a global array, making it easy to loop through the found folders to perform further actions, like creating files within them or searching them for other items.
Illustration
🗄️ Filing Cabinet Drawers: This command looks inside a specific filing cabinet (the parent path) and gives you a list of all the drawers (directories) that match your criteria, ignoring the individual paper files inside them.
Syntax
FIL.DIRS|Path|Array-No.[|DirPattern][|Options]
Parameter Explanation
P1 - Path - (String, Required)
The directory path to search in (e.g., C:\Users\).
P2 - Array-No. - (Numeric, Required)
The number (0-32) of the global array where the results will be stored.
P3 - DirPattern - (String, Optional)
A wildcard pattern to filter directory names (e.g., Pro*, ??mp). Defaults to * if omitted.
P4 - Options - (String, Optional)
A comma-separated string of keywords: SUBDIR, INFO, SORTUP, SORTDOWN.
Examples
'***********************************
' FIL.DIRS - Sample 1: Get all directories from the C:\ root
'***********************************
FIL.DIRS|C:\|1
' Get the summary from Array 1, element 0
ARR.Get Array|1|0|$$sum
VAR.$$cnt=PARSE$($$sum,",",3)
MBX.Found $$cnt directories in C:\.
ENR.
'
'***********************************
' FIL.DIRS - Sample 2: Get all subdirectories containing "Program"
'***********************************
FIL.DIRS|C:\|2|*Program*|SUBDIR,SORTUP
FIL.ArrayToVar|2|$$res
MBX.Found directories:$$crlf$$$$res
ENR.
Remarks
- This command only returns directories. To get files, use FIL.DIRF.
- Directory paths in the result array will always end with a backslash (\).
- Remember that element 0 of the array contains summary data, not a directory path.
See also:
• FIL.DIRF
• FIL.DIR