jon*_*jon 14 directory r copy-paste
我试图在R中批量移动不同种类的文件
origindir <- c("c:/origindir")
targetdir <- c("c/targetdir")
filestocopy <- c("myfile.doc", "myfile.rda", "myfile.xls",
"myfile.txt", "myfile.pdf", "myfile.R")
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法,但不知道如何处理所有文件:
file.copy(paste (origindir, "myfile.doc", sep = "/"),
paste (targetdir, "myfile.doc", sep = "/"),
overwrite = recursive, recursive = FALSE,
copy.mode = TRUE)
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么做.
A5C*_*2T1 16
正如Joran和Chase已经在评论中指出的那样,你需要做的就是:
file.copy(from=filestocopy, to=targetdir,
overwrite = recursive, recursive = FALSE,
copy.mode = TRUE)
Run Code Online (Sandbox Code Playgroud)
然后,如果您实际上正在移动文件,请删除原件:
file.remove(filestocopy)
Run Code Online (Sandbox Code Playgroud)