This function lists only the files in a specified directory, excluding
directories. It is useful when you need to process or analyze only the files
within a directory without including subdirectories. The base::list.files()
function lists both files and directories, so this function provides a more
convenient way to obtain just the files.
Arguments
- dirPath
Character. The path to the directory from which to list files.
- ...
Additional arguments passed to
base::list.files()
(e.g.,pattern
,recursive
). Note thatfull.names
will be ignored.
Examples
# \donttest{
listFiles(getwd())
#> [1] "/home/runner/work/FastUtils/FastUtils/docs/reference/FastUtils-package.html"
#> [2] "/home/runner/work/FastUtils/FastUtils/docs/reference/Rplot001.png"
#> [3] "/home/runner/work/FastUtils/FastUtils/docs/reference/add.html"
#> [4] "/home/runner/work/FastUtils/FastUtils/docs/reference/bound.html"
#> [5] "/home/runner/work/FastUtils/FastUtils/docs/reference/closestWord.html"
#> [6] "/home/runner/work/FastUtils/FastUtils/docs/reference/colToRownames.html"
#> [7] "/home/runner/work/FastUtils/FastUtils/docs/reference/createHash.html"
#> [8] "/home/runner/work/FastUtils/FastUtils/docs/reference/createMutator.html"
#> [9] "/home/runner/work/FastUtils/FastUtils/docs/reference/createPkgLoader.html"
#> [10] "/home/runner/work/FastUtils/FastUtils/docs/reference/divide.html"
#> [11] "/home/runner/work/FastUtils/FastUtils/docs/reference/enclose.html"
#> [12] "/home/runner/work/FastUtils/FastUtils/docs/reference/encloseBr.html"
#> [13] "/home/runner/work/FastUtils/FastUtils/docs/reference/enumerateit.html"
#> [14] "/home/runner/work/FastUtils/FastUtils/docs/reference/evalText.html"
#> [15] "/home/runner/work/FastUtils/FastUtils/docs/reference/findMissingRdSections.html"
#> [16] "/home/runner/work/FastUtils/FastUtils/docs/reference/fixColnames.html"
#> [17] "/home/runner/work/FastUtils/FastUtils/docs/reference/getAvgHex.html"
#> [18] "/home/runner/work/FastUtils/FastUtils/docs/reference/getChar.html"
#> [19] "/home/runner/work/FastUtils/FastUtils/docs/reference/getFailStr.html"
#> [20] "/home/runner/work/FastUtils/FastUtils/docs/reference/getPkgKeywords.html"
#> [21] "/home/runner/work/FastUtils/FastUtils/docs/reference/getPlotDims.html"
#> [22] "/home/runner/work/FastUtils/FastUtils/docs/reference/getUniquePairsUpTo.html"
#> [23] "/home/runner/work/FastUtils/FastUtils/docs/reference/getfirst.html"
#> [24] "/home/runner/work/FastUtils/FastUtils/docs/reference/getlast.html"
#> [25] "/home/runner/work/FastUtils/FastUtils/docs/reference/greplDir.html"
#> [26] "/home/runner/work/FastUtils/FastUtils/docs/reference/ind.html"
#> [27] "/home/runner/work/FastUtils/FastUtils/docs/reference/index.html"
#> [28] "/home/runner/work/FastUtils/FastUtils/docs/reference/initDataFrameWithColnames.html"
#> [29] "/home/runner/work/FastUtils/FastUtils/docs/reference/initEmptyTable.html"
#> [30] "/home/runner/work/FastUtils/FastUtils/docs/reference/initList.html"
#> [31] "/home/runner/work/FastUtils/FastUtils/docs/reference/initTestthat.html"
#> [32] "/home/runner/work/FastUtils/FastUtils/docs/reference/initV.html"
#> [33] "/home/runner/work/FastUtils/FastUtils/docs/reference/isBound.html"
#> [34] "/home/runner/work/FastUtils/FastUtils/docs/reference/isCamelCase.html"
#> [35] "/home/runner/work/FastUtils/FastUtils/docs/reference/isEven.html"
#> [36] "/home/runner/work/FastUtils/FastUtils/docs/reference/isOdd.html"
#> [37] "/home/runner/work/FastUtils/FastUtils/docs/reference/isPascalCase.html"
#> [38] "/home/runner/work/FastUtils/FastUtils/docs/reference/isSnakeCase.html"
#> [39] "/home/runner/work/FastUtils/FastUtils/docs/reference/isVowel.html"
#> [40] "/home/runner/work/FastUtils/FastUtils/docs/reference/joinRegex.html"
listFiles(getwd(), pattern = "\\.R$", recursive = TRUE)
#> character(0)
# }