在某些日期,我在名为 data
的文件夹中有几个文件(具有相同的暗淡):
file2011001.bin named like this "fileyearday"
file2011009.bin
file2011020.bin
.
.
file2011322.bin
某些日期(文件)丢失了。我需要的只是遍历这些文件
if file2011001.bin exist ok, if not copy any file in the directory and name it file2011001.bin
if file2011002.bin exist ok, if not copy any file in the directory and name it file2011002.bin and so on untill file2011365.bin
我可以在 R
中列出它们:
dir<- list.files("/data/", "*.bin", full.names = TRUE)
我想知道是否可以通过 R 或任何其他语言实现!
最佳答案
几乎如您所料:
AllFiles = paste0("file", 2010:2015, 0:364, ".bin")
for(file in AllFiles)
{
if(file.exists(file))
{
## do something
}
}
关于linux - 如何找到丢失的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33151509/