欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

同文件夹内文本搜索器(vbs)

程序员文章站 2022-08-06 10:20:40
同文件夹内文本搜索器(vbs)
<html><head><title>同文件夹内文本搜索器(vbs)</title>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<script language=vbscript id=clienteventhandlersvbs>
<!--
dim fso, f, f1, fc,fn,s,uf1,ufn
sub b1_onclick
fn=t1.value ''
pn=mid(location.pathname,2,len(location.pathname)-14)
showfolderlist(pn)
end sub

function showfolderlist(path)
''msgbox path
set fso = createobject("scripting.filesystemobject")
set f = fso.getfolder(path)
set fc = f.files
'' ufn=ucase(fn)
for each f1 in fc
filespec= path & f1.name
readentirefile(filespec)
'' uf1=ucase(f1.name)
'' if instr(uf1,ufn) <> 0 then
'' s=s & "<a href=" & path & f1.name & ">" & f1.name & "</a><br>"
'' end if
next
document.write "已搜索到以下条目,请单击之。[墨伯编制 于2003年元月]<br>"
document.write s
set fc=nothing
set f=nothing
set fso=nothing
end function

function readentirefile(filespec)
const forreading = 1
dim fso, thefile, retstring
set fso = createobject("scripting.filesystemobject")
set thefile = fso.opentextfile(filespec, forreading, false)
ufn=ucase(fn)
do while thefile.atendofstream<> true
retstring = thefile.readline
uf1=ucase(retstring)
if instr(uf1,ufn) <> 0 then
s=s & "<a href=" & path & f1.name & ">" & f1.name & "</a><br>"
exit do
end if
loop
thefile.close
readentirefile = s
end function

-->
</script>
</head>
<body>
<p align=center><font color=#000000 size=6>请输入要搜索[在正文中包含]的关键词(</font><font
color=#000000 size=3>忽略大小写</font><font color=#000000 size=6>)</font> </p>
<p align=center><font size=2><font color=#000000>[墨伯编制
于2003年1月5日]</font> </font> </p>
<p align=center><input name=t1><input type=button value=搜索! name=b1></p>
<p align=center> </p></body></html>