将文件夹从一个目录复制到R中的另一个目录

将文件夹从一个目录复制到R中的另一个目录

问题描述:

我有两个文件夹(例如 A, B)位于一个文件夹中(例如 Input)。我想将 A和 B复制到另一个文件夹(例如输出)。我可以在R中执行此操作吗?

I have two folders (say "A","B") which are in a folder (say "Input"). I want to copy "A" and "B" to another folder (say "Output"). Can I do this in R?

将当前目录文件复制到新目录中

Copying your current directory files to their new directories

currentfiles 是要复制的文件列表
newlocation 是目录您要复制到

currentfiles is a list of files you want to copy newlocation is the directory you're copying to

如果不列出当前文件,则需要遍历工作目录

If you aren't listing your current files, you'll need to loop through you're working directory

file.copy(from=currentfiles, to=newlocation, 
          overwrite = TRUE, recursive = FALSE, 
          copy.mode = TRUE)

这是用于删除旧文件

file.remove(currentfiles)