For the complete documentation index, see llms.txt. This page is also available as Markdown.
The .listfiles {path} {directories?} {recursive?} {pattern?} {fullpath?} {sortby?} {order?} docs ↗ function returns an iterable of entries from a directory.
By default, the result is an unordered collection of absolute paths to the immediate children of the directory at path. The path is interpreted relative to the main source file’s location, or as an absolute path. Use a slash (/) as the path separator, regardless of the operating system.
For the following examples, assume the following directory structure:
- assets
- folder
- file1.txt
- file2.txt
- file3.md
- subfolder
- nested-file1.txt
- nested-file2.txt
- nested-file3.md
.listfiles {assets/folder} fullpath:{no}file1.txt
file2.txt
file3.md
subfolder
The result is an iterable value, that can be passed to .foreach.
.foreach {.listfiles {assets/folder} fullpath:{no}}
name:
**File:** .nameFile: file1.txt
File: file2.txt
File: file3.md
File: subfolder
By default, each entry is returned as its absolute path:
.listfiles {assets/folder}/home/runner/work/quarkdown/quarkdown/docs/assets/folder/file1.txt
/home/runner/work/quarkdown/quarkdown/docs/assets/folder/file2.txt
/home/runner/work/quarkdown/quarkdown/docs/assets/folder/file3.md
/home/runner/work/quarkdown/quarkdown/docs/assets/folder/subfolder
This can be used in combination with .read to load file content:
.foreach {.listfiles {assets/folder} directories:{no}}
path:
Content of .path::filename::codespan is .path::read::codespanContent of file1.txt is File 1
Content of file2.txt is File 2
Content of file3.md is File 3
Setting recursive:{yes} walks every nested subdirectory and returns all descendants, not just the immediate children.
.listfiles {assets/folder} recursive:{yes} fullpath:{no}file1.txt
file2.txt
file3.md
subfolder
nested-file1.txt
nested-file2.txt
nested-file3.md
The root directory itself is never included in the result.
Passing a pattern keeps only entries whose bare file name matches the given regular expression. The pattern always applies to the file name alone (never to a directory path), regardless of fullpath or recursive.
.listfiles {assets/folder} pattern:{.*\.txt} recursive:{yes} fullpath:{no}file1.txt
file2.txt
nested-file1.txt
nested-file2.txt
Set directories:{no} to keep only files in the result, omitting subdirectories from the output:
.listfiles {assets/folder} directories:{no}/home/runner/work/quarkdown/quarkdown/docs/assets/folder/file1.txt
/home/runner/work/quarkdown/quarkdown/docs/assets/folder/file2.txt
/home/runner/work/quarkdown/quarkdown/docs/assets/folder/file3.md
By default, the order of the result is unspecified, and the returned iterable is unordered. Picking a sort criterion via sortby switches the result to an ordered iterable:
| Value | Effect |
|---|---|
none | No sorting; the result is an unordered collection (default). |
name | Sort by file name, using a human-friendly alphanumeric comparator. |
lastmodified | Sort by the file’s last-modified timestamp. |
The order parameter then chooses the direction:
ascending (default): smallest first (A-Z, oldest first).descending: largest first (Z-A, newest first)..listfiles {assets/folder} sortby:{name} order:{descending} fullpath:{no}subfolder
file3.md
file2.txt
file1.txt
Because the result is iterable, it composes naturally with .includeall:
This loads every file under chapters/ in alphabetical order:
.listfiles {chapters} sortby:{name}::includeall.listfiles follows the same permission model as the other file-reading functions:
project-read permission (granted by default).global-read (opt-in).