getlatestfile: Retrieve most recent file from a file path

View source: R/files_manage.R

getlatestfileR Documentation

Retrieve most recent file from a file path

Description

Retrieves the latest file name and modification details for a specified path with the option to only look include files with a defined name string and exclude files with other defined name strings. The function can be set to attempt file retrieval a defined number of times to overcome server connectivity problems.

Usage

getlatestfile(
  folder_path,
  file_string,
  exclusions,
  return_type,
  maxTries,
  include.dirs = FALSE,
  recursive = FALSE
)

Arguments

folder_path

Folder path containing the file to retrieve. Folders within this path will not be searched.

file_string

Character string within the file names to retrieve (optional). If not defined all file names within the folder are retrieved.

exclusions

Character string within the file names for file exclusion (optional). If not defined nothing is excluded from the retrieved file name list.

return_type

Use "all" to retrieve a data.frame with the file name, file path and modiciation date, "name" to retrieve the file name or "path" to retrieve the full file path. Default is "path". (optional)

maxTries

Maximum number of times to attempt file information retrieval. Default is 1. (optional)

include.dirs

list.files argument; Logical; return folders TRUE for yes, FALSE for no. Default is no.

recursive

list.files argument; Look in subdirectories

Value

Returns the last ctime file path, file name or a data.frame with the file name, path and modification details as defined by return_type where size is the file size in bytes, mtime is the last modification time, ctime is last status change time, atime is last access time.

Author(s)

Diane Hatziioanou

Examples

# Import latest file
# todays_file <- getlatestfile(file.path("...","subfolder","subfolder"),
#    return_type = "all", file_string = "epi", exclusions = "unwanted")
# df <- simpleimport(todays_file$path)

# Record the modification details
 # Data_as_of <- getlatestfile(folder_path = file.path("...","subfolder","subfolder"),
 #  file_string = "csv",exclusions = "unwanted",
 #  return_type = "all", maxTries = 5)$ctime


DHatziioanou/simpleepi documentation built on Sept. 24, 2024, 5:25 a.m.