如何递归地将csv文件从一个目录复制到另一个目录中

时间:2017-06-13 03:12:20

标签: r

我可以使用下面的代码复制文件/子目录,但我只想复制csv文件。

dir.create(new_directory)
file.copy(from = old_directory, to = new_directory, recursive = TRUE)

2 个答案:

答案 0 :(得分:1)

这应该有效:

fls <- list.files(pattern='*.csv')
file.copy(fls,
          to = "new_directory", recursive = TRUE,
          overwrite = TRUE, copy.mode = TRUE, copy.date = FALSE)

答案 1 :(得分:0)

你试过这个吗?

file.copy(from = "old_path/*.csv", to ="new_path/", recursive = TRUE)