FIL. - File and Directory Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Filesystem-Commands > FIL. - File-Commands > FIL.DIR-Commands >

FIL. - File and Directory Commands

FIL.DIR

Previous Top Next


SPR Script Language

 

FIL.DIR

Returns a list of both Files and Directories from a single path.

 

Intention

 

The FIL.DIR command is the most comprehensive of the single-folder scanning commands. It retrieves a complete listing of a directory's contents, including both files and subdirectories. It provides separate wildcard patterns for filtering files and folders independently. The combined results are stored in a single global array.

 

Illustration

🗄️📄 Open the Whole Drawer: This command opens a filing cabinet drawer (the path) and gives you a list of everything inside—both the hanging file folders (directories) and the loose papers (files) that match your criteria.

 

Syntax

 

FIL.DIR|Path|Array-No.[|DirPattern][|FilePattern][|Options]

 

Parameter Explanation

 

P1 - Path - (String, Required)

The directory path to search in.

 

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. Defaults to * if omitted.

 

P4 - FilePattern - (String, Optional)

A wildcard pattern to filter file names. Defaults to *.* if omitted.

 

P5 - Options - (String, Optional)

A comma-separated string of keywords: SUBDIR, INFO, SORTUP, SORTDOWN.

 

Examples

 

'***********************************

' FIL.DIR - Sample 1: Get all contents of the script path

'***********************************

FIL.DIR|?path\|1

' Get the summary from Array 1, element 0

ARR.Get Array|1|0|$$sum

VAR.$$tot=PARSE$($$sum,",",1)

VAR.$$fil=PARSE$($$sum,",",2)

VAR.$$dir=PARSE$($$sum,",",3)

MBX.Found $$tot total items:$$crlf$$$$fil Files$$crlf$$$$dir Directories

ENR.

'

'***********************************

' FIL.DIR - Sample 2: Get all TXT files and "Log" folders recursively

'***********************************

FIL.DIR|?desktop\|2|*Log*|*.txt|SUBDIR,SORTUP

FIL.ArrayToVar|2|$$res

MBX.Found items:$$crlf$$$$res

ENR.

 

Remarks

 

- This command is a combination of FIL.DIRF and FIL.DIRS.

- If you omit the DirPattern or FilePattern, they default to "*" and "*.*" respectively.

 

See also:

 

FIL.DIRF

FIL.DIRS

FIL.MFDIR