listfiles Synchronous

Get the files and folders directly inside a workspace directory. Each result is a workspace-relative path that can be passed to the other file functions. Use it to build a file chooser or process one directory. This is an immediate-child listing, so walk returned folders separately for a recursive traversal.

Syntax
Luau
listfiles(path: string) -> {string}

Parameters

Function parameters
ParameterTypeDescription
pathstringDirectory to list. Use an empty string for the workspace root.

Returns

{string}

An array of paths sorted by name. An empty folder returns an empty array; a missing folder raises an error.

Usage notes

Only immediate children are listed. Use isfolder to identify directories before listing their children.

Differences from Volt

Volt documents access through explicitly created workspace symlinks. Kawaii rejects symlinks in workspace paths; all workspace operations remain subject to its path containment checks.

Example

Example
Luau
for _, path in ipairs(listfiles("")) do
    if isfile(path) then
        print("File:", path)
    else
        print("Folder:", path)
    end
end
Kawaii documentation