> ## Documentation Index
> Fetch the complete documentation index at: https://errand.nuvrel.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# fileset

> Discover files matching a glob pattern.

`fileset(path, pattern)` returns a set of file paths matching `pattern` within `path`. The paths are relative to `path`. The set is unordered; use [`sort`](/functions/collection/sort) when order matters.

## Signature

```
fileset(path string, pattern string) set(string)
```

`pattern` supports `*` (any characters except `/`), `**` (any path components), and `?` (any single character).

## Example

Discover all SQL migration files and run them in alphabetical order:

```hcl theme={null}
computed "migrations" {
  description = "All SQL migration files"
  expression  = fileset(".", "migrations/*.sql")
}

task "migrate" {
  description = "Apply all pending migrations"
  commands = [
    "for f in ${join(" ", sort(computed.migrations))}; do psql -f $f && echo \"Applied $f\"; done",
  ]
}
```

All `.sql` files under `migrations/` are discovered and applied in alphabetical order, which corresponds to their numeric prefix order (e.g., `001_init.sql`, `002_users.sql`).

## Notes

* The returned paths are relative to `path`, not to the playbook directory.
* Use [`sort`](/functions/collection/sort) when you need a deterministic traversal order.
* Hidden files (starting with `.`) are not included unless the pattern explicitly matches them.
* Only files are returned, not directories.
