Returns names of files located in a given directory. It's similar to list.files() only with better defaults and behaviors.

list_files(path = ".", full = TRUE, all = FALSE, recursive = FALSE,
  pattern = NULL, ignore.case = FALSE, invert = FALSE)

Arguments

path

Directory from which to locate dirs–defaults to current working directory.

full

Logical indicating whether to return full paths. Defaults to TRUE.

all

Logical indicating whether to return all (include dot files) file names. Defaults to FALSE.

recursive

Logical indicating whether to recursively list files.

pattern

Regular expression pattern on which to filter (return) matching results. Defaults to NULL, meaning all qualifying files will be returned.

ignore.case

Logical indicating whether to ignore case if pattern is supplied–defaults to FALSE.

invert

Logical indicating whether to invert (return those that DO NOT match) regex matching results–defaults to FALSE.

Value

A character vector of directories

See also

Other list_paths: list_dirs, list_paths

Examples

## list files in working directory list_files()
#> [1] "/Users/mwk/R/fml/docs/reference/dir_create.html" #> [2] "/Users/mwk/R/fml/docs/reference/dir_exists.html" #> [3] "/Users/mwk/R/fml/docs/reference/dir_name.html" #> [4] "/Users/mwk/R/fml/docs/reference/dir_tmp.html" #> [5] "/Users/mwk/R/fml/docs/reference/dot-home.html" #> [6] "/Users/mwk/R/fml/docs/reference/dot-Renviron.html" #> [7] "/Users/mwk/R/fml/docs/reference/file_create.html" #> [8] "/Users/mwk/R/fml/docs/reference/file_exists.html" #> [9] "/Users/mwk/R/fml/docs/reference/file_info.html" #> [10] "/Users/mwk/R/fml/docs/reference/file_name.html" #> [11] "/Users/mwk/R/fml/docs/reference/file_path.html" #> [12] "/Users/mwk/R/fml/docs/reference/file_symlink.html" #> [13] "/Users/mwk/R/fml/docs/reference/file_tmp.html" #> [14] "/Users/mwk/R/fml/docs/reference/find_file.html" #> [15] "/Users/mwk/R/fml/docs/reference/fml-package.html" #> [16] "/Users/mwk/R/fml/docs/reference/fp.html" #> [17] "/Users/mwk/R/fml/docs/reference/here.html" #> [18] "/Users/mwk/R/fml/docs/reference/index.html" #> [19] "/Users/mwk/R/fml/docs/reference/list_dirs.html" #> [20] "/Users/mwk/R/fml/docs/reference/list_files.html" #> [21] "/Users/mwk/R/fml/docs/reference/list_paths.html" #> [22] "/Users/mwk/R/fml/docs/reference/match_files.html" #> [23] "/Users/mwk/R/fml/docs/reference/package_file.html" #> [24] "/Users/mwk/R/fml/docs/reference/path_expand.html" #> [25] "/Users/mwk/R/fml/docs/reference/read_access.html" #> [26] "/Users/mwk/R/fml/docs/reference/search_file.html" #> [27] "/Users/mwk/R/fml/docs/reference/write_access.html"