如何用vbs获取指定路径下的文件名并输出到文本文件

更新时间:02-04 教程 由 凛时年 分享

如何用vbs获取指定路径下的文件名并输出到文本文件?

把文本文件处理为数组,每行为一个数组元素,然后在每个元素中查找关键词,vbs可以直接使用instr函数来查找,也可以使用正则表达式查找。找到后把那个数组元素复制出来就可以了。第一种,使用instrc = split(createobject("scripting.filesystemobject").opentextfile("a.txt").readall,vbcrlf)for i = 0 to ubound(c)if instr(c(i),"nice") then msgbox c(i)next第二种,使用正则表达式c = split(createobject("scripting.filesystemobject").opentextfile("a.txt").readall,vbcrlf)for i = 0 to ubound(c)if rt("nice",c(i)) then msgbox c(i)nextFunction rt(patrn,str)set regex=new regexpregex.pattern = patrnregex.ignorecase = falsert = regex.test(str)End Function

声明:关于《如何用vbs获取指定路径下的文件名并输出到文本文件》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2193564.html