file-list(3)file-list - Generate list of matching file names
file-list "file-path-regex"
file-list is a macro language construct only that performs a recursive search for all files and directories that match the given file-path-regex. Unlike $file-names(5), the file-path-regex argument can have a regex at any point in the path, enabling the command to locate matching files in multiple locations.
The one restriction is that regex classes and special characters cannot and will not include the path separator character, i.e. giving the command a mask of "/foo/[a-z/]*/bar" to find any bar within /foo is not supported and the '.*' in "/foo/.*/bar" will only match files and directories in /foo. The only exception to this rule is for a trailing class which can contain a path character, e.g. the mask can end with "[^/]" to filter out any directories from the result.
On completion, the macro sets the command variable .file-list.file-count to the number of matches found, and the variables .file-list.file0, .file-list.file1, ..., .file-list.filen to each match, where n is the number of matches minus one, i.e. .file-list.file-count-1.
The following example can be used to locate the Rscript(1) interpreter on Windows, which is typically installed into C:\Program Files\R\R-<version>\bin\ folder:
file-list "C:/Program Files/R/R-\\d+\\.\\d+\\.\\d.*/bin/Rscript.exe" !if ¬ .file-list.file-count ml-write "ERROR: Failed to locate the Rscript interpreter" !abort !endif set-variable #l0 .file-list.file0 !iif &gre .file-count 1 ml-write &cat "Warning: Multiple Rscript interpreters found, using " #l0
The file-list command is not publically available from the command line, but may be used within macros to perform the copy.
This command is implemented as a recursive macro in utils.emf.
(c) Copyright JASSPA 2025
Last Modified: 2025/12/01
Generated On: 2025/12/01