listfiles

Lists a Workspace directory.

Syntax

Signature
listfiles(Path: string?) -> {string}

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
Pathstring?Workspace-relative directory. Defaults to the Workspace root.

Returns

TypeDescription
{string}Paths of the directory's immediate entries.

Notes

Omit Path or pass an empty string to list the Workspace root. Entries are returned as Workspace-relative paths.

Example

Luau
makefolder("Examples")
writefile("Examples/Hello.txt", "hello")

for _, Path in listfiles("Examples") do
    if isfile(Path) then
        print("File:", Path)
    elseif isfolder(Path) then
        print("Folder:", Path)
    end
end