工作中需要验证log文件内是否有指定字符,使用au3写了个小程序解放人力,过程中遇到了两个小问题如下: 如何查找log/trt文本文件中是否含有指定字符串? log文件和trt文件类似可以使用StringInStr(FileRead($filepath),”block”) 遍历文件中是否含有指定字符串。 如何获取指定文件夹内的所有文件名? au3用户自定义函数中的_FileListToArray(“C:\6san\acclog”)可以满足需求。 #Include $FileList=_FileListToArray(“C:\6san\acclog”) ;获取指定文件夹内的文件名 $i=1 While $i<=$FileList[0] $filepath=”C:\6san\acclog\”&$FileList[$i] If StringInStr(FileRead($filepath),”block”) Then ;查找字符 MsgBox(0, ‘ok’, $FileList[$i]) ;找到字符后弹窗提示字符所在文件 EndIf $i=$i+1 WEnd