|
<< 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.GetDir
Returns a directory listing directly to a single string variable.
Intention
The FIL.GetDir command provides a quick and convenient way to get a directory listing without using the global array system. It scans a path for files and/or directories and formats the entire result into a single string variable. Each line in the string is separated by a carriage return-line feed ($crlf$) and contains tab-separated details about the item, making it easy to parse or display.
Illustration
📠 Fax Machine: Instead of delivering a large box of documents (an array), this command sends you a single, neatly formatted report (a string variable) with a summary of all the items found. It's quick, direct, and easy to read.
Syntax
FIL.GetDir|$$DestVar[|PathWithWildcard][|Options]
Parameter Explanation
P1 - $$DestVar - (Variable, Required)
The variable where the final, CR-LF delimited result string will be stored.
P2 - PathWithWildcard - (String, Optional)
The path and file pattern to search for (e.g., C:\Temp\*.log). Defaults to *.* in the current directory if omitted.
P3 - Options - (String, Optional)
A comma-separated string of keywords: SUBDIR, FILESONLY, DIRSONLY, SORTBYSIZE.
Examples
'***********************************
' FIL.GetDir - Sample 1: Get all files and folders in the script path
'***********************************
FIL.GetDir|$$res|?path\*.*
MBX.Found items in script path:$crlf$$$res
ENR
'
'***********************************
' FIL.GetDir - Sample 2: Get only directories, sorted by size (name)
'***********************************
FIL.GetDir|$$res|C:\*|DIRSONLY,SORTBYSIZE
MBX.Found directories in C:\:$crlf$$$res
ENR.

Remarks
- The output format is always a tab-separated string: [TYPE]<tab>FullPath<tab>Size<tab>Attributes.
- Unlike the array-based commands, this command does not have separate `SORTUP` or `SORTDOWN` options. `SORTBYSIZE` is the only available sort.
- This command does not return a value on the stack; the result is placed directly into the destination variable.
See also:
• FIL.DIR