gpt4 book ai didi

linux - 如何找到丢失的文件?

转载 作者:太空宇宙 更新时间:2023-11-04 10:45:51 25 4
gpt4 key购买 nike

在某些日期,我在名为 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com