date=`date +%F`
path=/root/bkp
for i in $(ls $path)
do
str=`find $path/$i -name “*$date*.txt”`
if [$str]
then
echo “File in $i is OK”
else
echo “File in $i is not found”
fi
done
import os,datetime
path = "C:\\Temp"
date=datetime.date.today()
pattern=str('%s' %date)
filefound = False
def find_file(currpath):
for dirname, dirnames, filenames in os.walk(currpath):
for files in filenames:
if pattern in files:
print("File found in " + currpath)
global filefound
filefound = True
return
for directory in dirnames:
find_file(path+"\\"+directory)
find_file(path)
if filefound == False:
print("File containing " + pattern + " not found in " + path)
我对这个问题有点困惑,但是如果你只是在寻找文件名中是否有模式,那么你已经很清楚了。在
编辑:递归地遍历每个目录
相关问题 更多 >
编程相关推荐