dot-findFile: Find Recent File Information

.findFileR Documentation

Find Recent File Information

Description

Find recent file information based on folder and file name (allows for wildcard structure)

Usage

.findFile(folder = ".", file = "*.*", n = 1, fileNameOnly = TRUE)

Arguments

folder

folder (i.e., directory to look in, can use relative path )

file

file (can use wildcards, e.g., "*.csv")

n

number of files to return (e.g., value of 1 returns most recent file, value of 'all' returns all files)

fileNameOnly

logical field, if TRUE only return file name

Details

This function is used to search a selected directory for information about the most recently modified files in that directory. The default setting searches the current working directory. Relative directory addresses can be used. The default settings returns the name of the most recently modified file. Employing wildcards in the file argument can narrow the file search, e.g., "*.csv" will only return comma delimited files.

The default setting for the argument, n (of 1), will only return a single file. This value can be increased to any number (2, 3,...) to change the maximum number of files returned; or the argument can be set to 'all' to return all files. Setting the argument, fileNameOnly, to FALSE will result in returning additional file meta data related to file size, modified date/time and create date/time.

The results are in descending order of modified date/time.

Value

returns file name as a character string

Examples

# name of most recently modified file
## Not run: 
.findFile()         # current directory
.findFile("..")     # one directory up
#
# list of files and common attributes one directory up
.findFile(folder="..", file="*.*", n=2, fileNameOnly=FALSE)      
                                                       #two most recent files
.findFile(folder="..", file="*.*", n="all", fileNameOnly=FALSE)  #all files

## End(Not run)

leppott/baytrends documentation built on Nov. 2, 2024, 6:42 p.m.