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   16 FALSE  644 2024-10-23 10:51:42 2024-10-23 10:51:42
#> 2     autoline.html   20 FALSE  644 2024-10-23 10:51:42 2024-10-23 10:51:42
#> 3 balance_data.html    9 FALSE  644 2024-10-23 10:51:42 2024-10-23 10:51:42
#>                 atime  uid gid  uname grname
#> 1 2024-10-23 10:51:42 1001 127 runner docker
#> 2 2024-10-23 10:51:42 1001 127 runner docker
#> 3 2024-10-23 10:51:42 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
#> 130    li_auth.html    6 FALSE  644 2024-10-23 10:52:16 2024-10-23 10:52:16
#> 131 li_profile.html    6 FALSE  644 2024-10-23 10:52:16 2024-10-23 10:52:16
#> 132  list_cats.html   11 FALSE  644 2024-10-23 10:52:16 2024-10-23 10:52:16
#>                   atime  uid gid  uname grname
#> 130 2024-10-23 10:52:16 1001 127 runner docker
#> 131 2024-10-23 10:52:16 1001 127 runner docker
#> 132 2024-10-23 10:52:16 1001 127 runner docker

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