|
<< 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.MFDIR
Searches for Files across multiple folders using wildcards in the path.
Intention
The FIL.MFDIR command (Multi-Folder DIR) is a powerful search tool that allows you to use wildcards (*, ?) in the directory parts of a path.
It first finds all directories that match the path pattern and then searches within each of those directories for files matching the file pattern.
This command returns files only.
Illustration
🗺️ Treasure Map: This command is like having a treasure map where part of the location is smudged (e.g., "C:\Users\*\Documents"). It first finds all possible locations matching the map, then digs in each spot for the treasure (the files).
Syntax
FIL.MFDIR|Array-No.|PathWithWildcards[|Options]
Parameter Explanation
P1 - Array-No. - (Numeric, Required)
The number (0-32) of the global array where the results will be stored.
P2 - PathWithWildcards - (String, Required)
The full path specification. Wildcards (*, ?) can be used in the directory parts and in the final filename part. Example: C:\Users\*\AppData\Local\*.log.
P3 - Options - (String, Optional)
A comma-separated string of keywords: INFO, SORTUP, SORTDOWN. Note: `SUBDIR` is not needed as the path pattern implies recursion.
Examples
'***********************************
' FIL.MFDIR - Sample 1: Find all user INI files
'***********************************
' Find all .ini files in the AppData\Roaming folder for ALL users
FIL.MFDIR|1|C:\Users\*\AppData\Roaming\*.ini
FIL.ArrayToVar|1|$$res
MBX.Found INI files:$$crlf$$$$res
ENR.
'
'***********************************
' FIL.MFDIR - Sample 2: Find all executables in Program Files subfolders
'***********************************
' Find all .exe files in any subfolder of both "Program Files" and "Program Files (x86)"
FIL.MFDIR|2|C:\Program Files*\*\*.exe|SORTUP
ARR.Get Array|2|0|$$sum
MBX.Found $$sum executables.
ENR.
Remarks
- This command performs a two-phase search: first it finds all matching directories, then it searches for files within them. This can be a slow operation on large file systems.
- The `SUBDIR` option is not applicable here because the directory pattern itself defines the recursive nature of the search.
See also:
• FIL.DIRF