Skip to contents

This function lets the user list all files on a given directory. It also lets filter files which contains a string.

Usage

listfiles(folder = getwd(), recursive = TRUE, regex = NA, images = FALSE)

Arguments

folder

Character. Directory which contains files

recursive

Boolean. Should the listing recurse into directories?

regex

Character. String to use for filtering files

images

Boolean. Bring only image files?

Value

data.frame with relevant data for each file on folder directory.

Examples

# All files in current directory (without recursive files)
df <- listfiles(recursive = TRUE)
head(df, 3)
#>       filename size isdir mode               mtime               ctime
#> 1     ROC.html   19 FALSE  644 2024-03-07 11:12:08 2024-03-07 11:12:08
#> 2 Rplot001.png    0 FALSE  644 2024-03-07 11:12:49 2024-03-07 11:12:49
#> 3 Rplot002.png   10 FALSE  644 2024-03-07 11:12:41 2024-03-07 11:12:41
#>                 atime  uid gid  uname grname
#> 1 2024-03-07 11:12:08 1001 127 runner docker
#> 2 2024-03-07 11:12:08 1001 127 runner docker
#> 3 2024-03-07 11:12:12 1001 127 runner docker

# All files in current directory (with recursive files)
df <- listfiles(recursive = TRUE)
tail(df, 3)
#>            filename size isdir mode               mtime               ctime
#> 142    li_auth.html    8 FALSE  644 2024-03-07 11:12:49 2024-03-07 11:12:49
#> 143 li_profile.html    8 FALSE  644 2024-03-07 11:12:49 2024-03-07 11:12:49
#> 144  list_cats.html   13 FALSE  644 2024-03-07 11:12:50 2024-03-07 11:12:50
#>                   atime  uid gid  uname grname
#> 142 2024-03-07 11:12:49 1001 127 runner docker
#> 143 2024-03-07 11:12:49 1001 127 runner docker
#> 144 2024-03-07 11:12:50 1001 127 runner docker

# Check R files using regex
df <- listfiles(regex = "\\.R$")