R/pathKeyWord.R

Defines functions pathKeyWord

Documented in pathKeyWord

#'pathKeyWord
#' @param drive a character string indicating the main drive
#' @param dir a character string indicating the main folder
#' @param ext a character string indicating the file extension when searching for specific files (e.g. '.xlsx')
#' @param recursive a boolean variable indicating whether the listing into directories is recursive i.e. whether files within subfolders present in the parent folder (\code{dir}) should be listed or not.  
#' @return pathKeyWord returns a string of class character with the entire path of the file, joining \code{drive}, \code{dir} and specified files
#' @description pathKeyWord takes as input character strings for the drive name, folder name and file name, and produces a string joining the \code{drive}, \code{dir} and specififed file names
#' @examples
#' pathKeyWord("D","Folder","key")
#' @export
pathKeyWord<-function(drive,dir,ext,recursive=TRUE)
{
  folders<-list.files(paste(drive,":/",dir,sep=""),
             recursive=recursive)[grep(ext,
                                  list.files(paste(drive,":/",dir,sep=""),
                                             recursive=recursive))]
  path<-paste(drive,":/",dir,"/",folders,sep="")
  return(path)
}
lwTools/agriTrf documentation built on March 26, 2020, 12:09 a.m.