get_latest_file: Get latest file

View source: R/get_latest_file.R

get_latest_fileR Documentation

Get latest file

Description

Get latest file

Usage

get_latest_file(path, pattern = NULL, full.names = TRUE, ...)

Arguments

path

Path to a directory to search within

pattern

Pattern of files to look for

full.names

Should the complete paths be returned?

...

Other arguments for list.files

Details

I have a habit of putting the YYYYMMDD date into the files that I save in order to keep old versions. This function helps find the last version of a file by extracting those 8 digit strings, finding a maximumn, and returning the file(s) that have that max in their name. Note that this will totally crash and burn if the dates are in another format or there are other 8+ digit sequences in the file names.

Value

a character representation of a path

Author(s)

Sven Halvorson (svenpubmail@gmail.com)

See Also

list.files

Examples

get_latest_file(
  path = '//psi-svr-filer.uoregon.edu/P50/radx_latinx_collection/data/external/site_info',
  pattern = 'cleaned_schedule'
)

svenhalvorson/SvenR documentation built on Aug. 25, 2023, 1:31 p.m.