#' File cleanup
#'
#' Removes files with names that match the given pattern
#' @param root_dir The root directory path, as string.
#' @param recursive_list TRUE or FALSE, indicates if subfolders are checked or not
#' @param pattern_match pattern string for matching files. Can be supplied with regular expressions
#' @export
#' @examples
#' file_cleanup(root_dir = "C:/Users/Administrator/Desktop/", recursive_list = TRUE, pattern_match = "\\(1\\)\\.")
file_cleanup <- function(root_dir, recursive_list = FALSE, pattern_match) {
files <- paste(root_dir, list.files(root_dir, recursive = recursive_list, pattern = pattern_match), sep="/")
decision <- menu(c("yes", "no"), title = paste("There are", length(files), "file(s) listed for deletion. Do you wish to proceed?"))
if (decision == 1) {
for(i in files){
file.remove(i)
}
} else {
print("It is always wise to double check. /Abraham Lincoln, 1976/")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.