R/moveToOld.R

#' Move a file to the old directory
#' 
#' Moves the file to the folder named "old" in the directory provided in the 
#'    `folder` attribute, from the `folder`.
#'    
#' @param file_name Name of the file.
#' @param folder Full (or relative) path to the folder with files.
moveToOld <- 
  function(file_name, folder, oldName = "old") {
    
    dir.create(str_c(folder,"/",oldName), showWarnings = FALSE)
    
    suppressWarnings(file.copy(from = str_c(folder, file_name),
                               to = str_c(folder, "/",oldName,"/", file_name), 
                               overwrite = TRUE, 
                               copy.date = TRUE))
    
    invisible(file.remove(str_c(folder, file_name)))
    
  }
EBukin/tradeAnalysis-pack documentation built on May 23, 2019, 8:25 p.m.