Skip to contents

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.

Usage

listFiles(dirPath, ...)

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 that full.names will be ignored.

Value

A character vector of file paths.

Examples

# \donttest{
listFiles(getwd())
#>  [1] "/home/runner/work/FastUtils/FastUtils/docs/reference/FastUtils-package.html"        
#>  [2] "/home/runner/work/FastUtils/FastUtils/docs/reference/add.html"                      
#>  [3] "/home/runner/work/FastUtils/FastUtils/docs/reference/bound.html"                    
#>  [4] "/home/runner/work/FastUtils/FastUtils/docs/reference/closestWord.html"              
#>  [5] "/home/runner/work/FastUtils/FastUtils/docs/reference/colToRownames.html"            
#>  [6] "/home/runner/work/FastUtils/FastUtils/docs/reference/createHash.html"               
#>  [7] "/home/runner/work/FastUtils/FastUtils/docs/reference/createMutator.html"            
#>  [8] "/home/runner/work/FastUtils/FastUtils/docs/reference/createPkgLoader.html"          
#>  [9] "/home/runner/work/FastUtils/FastUtils/docs/reference/divide.html"                   
#> [10] "/home/runner/work/FastUtils/FastUtils/docs/reference/enclose.html"                  
#> [11] "/home/runner/work/FastUtils/FastUtils/docs/reference/encloseBr.html"                
#> [12] "/home/runner/work/FastUtils/FastUtils/docs/reference/enumerateit.html"              
#> [13] "/home/runner/work/FastUtils/FastUtils/docs/reference/evalText.html"                 
#> [14] "/home/runner/work/FastUtils/FastUtils/docs/reference/findMissingRdSections.html"    
#> [15] "/home/runner/work/FastUtils/FastUtils/docs/reference/fixColnames.html"              
#> [16] "/home/runner/work/FastUtils/FastUtils/docs/reference/getAvgHex.html"                
#> [17] "/home/runner/work/FastUtils/FastUtils/docs/reference/getChar.html"                  
#> [18] "/home/runner/work/FastUtils/FastUtils/docs/reference/getFailStr.html"               
#> [19] "/home/runner/work/FastUtils/FastUtils/docs/reference/getPkgKeywords.html"           
#> [20] "/home/runner/work/FastUtils/FastUtils/docs/reference/getPlotDims.html"              
#> [21] "/home/runner/work/FastUtils/FastUtils/docs/reference/getUniquePairsUpTo.html"       
#> [22] "/home/runner/work/FastUtils/FastUtils/docs/reference/getfirst.html"                 
#> [23] "/home/runner/work/FastUtils/FastUtils/docs/reference/getlast.html"                  
#> [24] "/home/runner/work/FastUtils/FastUtils/docs/reference/greplDir.html"                 
#> [25] "/home/runner/work/FastUtils/FastUtils/docs/reference/ind.html"                      
#> [26] "/home/runner/work/FastUtils/FastUtils/docs/reference/index.html"                    
#> [27] "/home/runner/work/FastUtils/FastUtils/docs/reference/initDataFrameWithColnames.html"
#> [28] "/home/runner/work/FastUtils/FastUtils/docs/reference/initEmptyTable.html"           
#> [29] "/home/runner/work/FastUtils/FastUtils/docs/reference/initList.html"                 
#> [30] "/home/runner/work/FastUtils/FastUtils/docs/reference/initTestthat.html"             
#> [31] "/home/runner/work/FastUtils/FastUtils/docs/reference/initV.html"                    
#> [32] "/home/runner/work/FastUtils/FastUtils/docs/reference/isBound.html"                  
#> [33] "/home/runner/work/FastUtils/FastUtils/docs/reference/isCamelCase.html"              
#> [34] "/home/runner/work/FastUtils/FastUtils/docs/reference/isEven.html"                   
#> [35] "/home/runner/work/FastUtils/FastUtils/docs/reference/isOdd.html"                    
#> [36] "/home/runner/work/FastUtils/FastUtils/docs/reference/isPascalCase.html"             
#> [37] "/home/runner/work/FastUtils/FastUtils/docs/reference/isSnakeCase.html"              
#> [38] "/home/runner/work/FastUtils/FastUtils/docs/reference/isVowel.html"                  
#> [39] "/home/runner/work/FastUtils/FastUtils/docs/reference/joinRegex.html"                
listFiles(getwd(), pattern = "\\.R$", recursive = TRUE)
#> character(0)
# }