我有一个源文件夹
目标文件夹
我想要从源文件夹复制到目标文件夹的文件列表,该文件夹已保存到 .txt 文件
listtocopy.txt 如下 - 不确定它是否重要,但它们是 Anabat ZC 文件。
S5281925.35#
S5282317.26#
S5290100.39#
S5281859.28#
S5281932.18#
S5290420.20#
我不想复制所有文件。
我是 R 新手 - 这是我到目前为止所拥有的 - 但它不起作用。我认为它没有将该列表识别为文件名“列表”。
# Copy based on list
# identify the folders
current.folder <- "H:/Documents/1_PhD_Network/Auto_ID/Anabat7_11"
new.folder <- "H:/Documents/1_PhD_Network/Auto_ID/Scan_outputs"
#read listtocopy and assign to list
list<-read.delim("H:/Documents/1_PhD_Network/Auto_ID/Scan_outputs/listtocopy.txt")
# copy the files to the new folder
file.copy(list, new.folder)
我认为文本文件的读取方式有问题?
无论如何,这有效。感谢所有的回答。
# identify the folders
current.folder <- "C:/Users/Amanda/Desktop/testcopy/Anabat7_11"
new.folder <- "C:/Users/Amanda/Desktop/testcopy/Scan_outputs"
# find the files that you want
list_of_files <- read.delim("listtocopy.txt",header = F)
#check
print(list_of_files)
#copy vector
setwd(current.folder)
for(i in list_of_files)
{
file.copy(i, new.folder)
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)