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   17 FALSE  644 2026-01-07 12:44:58 2026-01-07 12:44:58
#> 2     autoline.html   21 FALSE  644 2026-01-07 12:44:59 2026-01-07 12:44:59
#> 3 balance_data.html   10 FALSE  644 2026-01-07 12:44:59 2026-01-07 12:44:59
#>                 atime  uid  gid  uname grname
#> 1 2026-01-07 12:44:58 1001 1001 runner runner
#> 2 2026-01-07 12:44:59 1001 1001 runner runner
#> 3 2026-01-07 12:44:59 1001 1001 runner runner

# All files in current directory (with recursive files)
df <- listfiles(recursive = TRUE)
tail(df, 3)
#>            filename size isdir mode               mtime               ctime
#> 128 lasso_vars.html   12 FALSE  644 2026-01-07 12:45:41 2026-01-07 12:45:41
#> 129 left_right.html    9 FALSE  644 2026-01-07 12:45:41 2026-01-07 12:45:41
#> 130  list_cats.html   12 FALSE  644 2026-01-07 12:45:41 2026-01-07 12:45:41
#>                   atime  uid  gid  uname grname
#> 128 2026-01-07 12:45:41 1001 1001 runner runner
#> 129 2026-01-07 12:45:41 1001 1001 runner runner
#> 130 2026-01-07 12:45:41 1001 1001 runner runner

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