Skip to contents

This will return the latest created file matching the criteria. It uses fs::dir_info() to find the files then picks the one with the latest birthtime.

Usage

find_latest_file(directory, regexp, selection_method = "modification_date")

Arguments

directory

The directory in which to search.

regexp

a regular expression passed to fs::dir_info() to search for the file.

selection_method

Valid arguments are "modification_date" (the default) or "file_name".

Value

the fs::path() to the file

Examples

if (FALSE) { # \dontrun{
find_latest_file(
  directory = "/conf/linkage/output/lookups/Unicode",
  regexp = "Scottish_Postcode_Directory_.+?\\.rds"
)
} # }