# listfiles

    .listfiles path:{String} \
        directories:{Boolean = true} \
          recursive:{Boolean = false} \
            pattern:{String? = null} \
           fullpath:{Boolean = true} \
             sortby:{FileSorting = FileSorting.NONE} \
              order:{Ordering = Ordering.ASCENDING}
    -> Iterable<String>

Content copied to clipboard

Lists the files located in a directory.

#### Return

a collection of string values, each representing an entry (file or directory) located in the directory. The collection is unordered when sortby is FileSorting.NONE, and ordered otherwise.

#### Parameters

path

directory path

directories

- Optional

whether to include directories in the listing

recursive

- Optional
- Likely named

whether to recursively list files in nested subdirectories

pattern

- Optional
- Likely named

optional regular expression to filter entries by name. When non-`null`, only entries whose file name (always the bare name, regardless of fullpath) matches the pattern are returned.

fullpath

- Optional

whether to return the absolute path of each file, rather than just the file name

sortby

- Optional

criterion to sort the files by

#### Values

- `none`
- `name`
- `lastmodified`

order

- Optional
- Likely named

order to sort the files in

#### Values

- `ascending`
- `descending`

#### See also

fileName

to exclude the extension from file names

#### Throws

IllegalArgumentException

if the directory does not exist, is not a directory, or if pattern is not a valid regular expression

#### Permissions

project-read
to list files located in the project directory
global-read
to list files located outside the project directory

#### Wiki page

listing-files