将文件夹从一个目录复制到R中的另一个目录 [英] Copy folders from one directory to another in R

查看:116
本文介绍了将文件夹从一个目录复制到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)

这篇关于将文件夹从一个目录复制到R中的另一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆