Copy folder recursive in R

后端 未结 6 939
谎友^
谎友^ 2021-02-13 17:27

Am I missing something in the functions?
I want to copy a folder with some files and another subfolder from one location to another. I tried to use file.copy(from, to,

6条回答
  •  生来不讨喜
    2021-02-13 18:08

    I'd rather write an R function that copies the directory using the Terminal. Here's what I use, but note that I wrote it only for Linux and OSX thus far.

    dir.copy <- function(from, to) {
      os <- Sys.info()['sysname']
      if (os == "Darwin" || os == "Linux") {
        command <- sprintf("cp -R '%s' '%s'", from, to)
        system(command, intern = TRUE)   
      }
    }
    

    Quick, easy, and works like a charm.

提交回复
热议问题