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.DIRF

Previous Top Next


SPR Script Language

 

FIL.DIRF

Returns a list of Files from a single directory path.

 

Intention

 

The FIL.DIRF command is used to get a list of files from a specific directory.

It allows you to filter the results using wildcard patterns and can optionally scan into subdirectories.

The results are stored in one of the global arrays for further processing.

 

This command is ideal when you need to perform actions on a group of files, such as reading their contents, moving them, or deleting them in a loop.

 

Illustration

📄 File Cabinet: This command goes to a specific file cabinet (the directory), pulls out all the paper documents (files) that match your criteria (the pattern), and hands you the stack (the array).

 

Syntax

 

FIL.DIRF|Path|Array-No.[|FilePattern][|Options]

 

Parameter Explanation

 

P1 - Path - (String, Required)

The directory path to search in (e.g., C:\Temp\ or ?path\).

 

P2 - Array-No. - (Numeric, Required)

The number (0-32) of the global array where the results will be stored.

 

P3 - FilePattern - (String, Optional)

A wildcard pattern to filter files (e.g., *.txt, image??.jpg). Defaults to *.* if omitted.

 

P4 - Options - (String, Optional)

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

INFO – Include extra fields in each result: `FullPath | Size | Attributes`.

SUBDIR – Also scan subdirectories recursively.

SORTUP – Sort the results alphabetically (case-insensitive), in ascending order (A → Z).

SORTDOWN – Sort the results alphabetically (case-insensitive), in descending order (Z → A).

SORTBYSIZE – Sort the results by size in ascending order (smallest → largest).

SORTBYSIZE,SORTDOWN – Sort the results by size in descending order (largest → smallest).

 

 

 

Examples

 

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

' FIL.DIRF - Sample 1: Get all INI files from the Windows directory

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

FIL.DIRF|?ws\|1|*.ini

' Get the summary from Array 1, element 0

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

ARR.Show|1

MBX.!

ENR.

 

clip1108

In Element 0 of the Array you will find: Used-total: 2, Files: 2, Dirs: 0 

 

 

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

' FIL.DIRF - Sample 1: Get all INI files from the Windows directory

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

FIL.DIRF|?ws\|1|*.ini|SUBDIR,INFO,SORTDOWN,SORTBYSIZE

' Get the summary from Array 1, element 0

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

ARR.Show|1

MBX.!

ENR.

 

clip1110

 

Remarks

 

- This command only returns files. To get directories, use FIL.DIRS.

- The destination array is cleared before the command runs.

- Remember that element 0 of the array contains summary data, not a file path.

 

See also:

 

FIL.DIRS

FIL.DIR

FIL.MFDIR

FIL.ArrayToVar