ls_files() is equivalent to the Unix ls command, and it works across
platforms. It can list files and directories that match a regular expression
pattern.
Details
ls_files():
Handles both single and multiple paths.
Supports regular expression filtering.
Removes system-specific directories (e.g., @eaDir).
Returns full paths.
See also
vignette("org"), whose "Troubleshooting" section uses this
function to check which files a project will source.
Other file utilities:
loc_per_file(),
move_directory(),
path(),
write_text()
Examples
# \donttest{
# List all files in current directory
org::ls_files()
#> [1] "/home/runner/work/org/org/docs/reference/cat_to_filepath_function_factory.html"
#> [2] "/home/runner/work/org/org/docs/reference/check_max_loc_per_file.html"
#> [3] "/home/runner/work/org/org/docs/reference/check_missing_packages.html"
#> [4] "/home/runner/work/org/org/docs/reference/do_install_missing_packages.html"
#> [5] "/home/runner/work/org/org/docs/reference/extract_packages.html"
#> [6] "/home/runner/work/org/org/docs/reference/figures"
#> [7] "/home/runner/work/org/org/docs/reference/find_missing_packages.html"
#> [8] "/home/runner/work/org/org/docs/reference/index.html"
#> [9] "/home/runner/work/org/org/docs/reference/initialize_project.html"
#> [10] "/home/runner/work/org/org/docs/reference/initialize_project_folders.html"
#> [11] "/home/runner/work/org/org/docs/reference/loc_one_file.html"
#> [12] "/home/runner/work/org/org/docs/reference/loc_per_file.html"
# List only R files
org::ls_files(regexp = "\\.R$")
#> character(0)
# List files in multiple directories
org::ls_files(c("dir1", "dir2"))
#> [[1]]
#> character(0)
#>
#> [[2]]
#> character(0)
#>
# }
