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?
我有两个文件夹(例如“A”,“B”),它们位于一个文件夹中(比如“输入”)。我想将“A”和“B”复制到另一个文件夹(比如“输出”)。我可以在R中这样做吗?
2 个解决方案
#1
8
Copying your current directory files to their new directories
将当前目录文件复制到新目录
currentfiles
is a list of files you want to copy newlocation
is the directory you're copying to
currentfiles是要复制的文件列表newlocation是要复制到的目录
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)
This is for deleting your old files
这是为了删除旧文件
file.remove(currentfiles)
#2
1
I am late. This is my simple approach that gets things done. In R,
我迟到了。这是我完成任务的简单方法。在R中,
current_folder <- "C:/Users/Bhabani2077/Desktop/Current"
new_folder <- "C:/Users/Bhabani2077/Desktop/Ins"
list_of_files <- list.files(current.folder, ".py$")
# ".py$" is the type of file you want to copy. Remove if copying all types of files.
file.copy(file.path(current_folder,list_of_files), new_folder)
#1
8
Copying your current directory files to their new directories
将当前目录文件复制到新目录
currentfiles
is a list of files you want to copy newlocation
is the directory you're copying to
currentfiles是要复制的文件列表newlocation是要复制到的目录
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)
This is for deleting your old files
这是为了删除旧文件
file.remove(currentfiles)
#2
1
I am late. This is my simple approach that gets things done. In R,
我迟到了。这是我完成任务的简单方法。在R中,
current_folder <- "C:/Users/Bhabani2077/Desktop/Current"
new_folder <- "C:/Users/Bhabani2077/Desktop/Ins"
list_of_files <- list.files(current.folder, ".py$")
# ".py$" is the type of file you want to copy. Remove if copying all types of files.
file.copy(file.path(current_folder,list_of_files), new_folder)