how to remove all .Rhistory file?

remove all .Rhistory file from my computer

As this involves 'unlink' to delete data from a device, use with extreme caution / at your own risk. i.e. the last line modifies your computer.

exact_file_name <- ".Rhistory"

library(shinyFiles)
library(purrr)
library(glue)

(drives <- getVolumes()())
## drives <-getwd() # if you dont need over every drive but from some base path like a working directory you can do this instead
(list_of_files_to_delete <- map(drives,
    ~{      file.path(.x,list.files(path = .x,
                 pattern = glue("^{exact_file_name}$"),
                 recursive = TRUE,all.files = TRUE))
    }) %>% unlist())

 walk(list_of_files_to_delete,unlink)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.