怎样用vbs代码实现查找某个文本文件中的某个字符串并写出到另一个文件?(输出包含该字符串的行)
[ Last edited by s11ss on 2007-12-14 at 04:24 PM ]
[ Last edited by s11ss on 2007-12-14 at 04:24 PM ]
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
| 评分人 | 分数 | 时间 |
|---|---|---|
| s11ss | +4 | 2007-12-12 21:06 |
Originally posted by s11ss at 2007-12-12 21:10:
vkill兄知道不知道用cscript执行vbs时是否有类似cls的清屏命令?

<html>
<title>cls</title>
<HTA:APPLICATION
ID="MyhyliApp"
APPLICATIONNAME="cls"
BORDER="thin"
BORDERSTYLE="normal"
VERSION="1.0"
SCROLL="no"
INNERBORDER="yes"
CONTEXTMENU="yes"
CAPTION="yes"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal"
NAVIGABLE="yes"
/>
<script language="VBScript">
windowswidth = 640
windowsheight = 480
window.resizeTo windowswidth, windowsheight
ileft=(window.screen.width-windowswidth)/2
itop=(window.screen.height-windowsheight)/2
window.moveTo ileft,itop
</script>
<body bgcolor=#e0e0e0>
<table align="center">
<tr>
<td align="center">清除后用F5刷新</td>
</tr>
<tr>
<td id="Menu" align="center"></td>
</tr>
</table>
<table width="100%" style="position:absolute; bottom:20px;"><td>
<table align="center" style="font:bold 15px 宋体;">
<tr align="center">
<td><button onclick="CLS1" style="width:100;">清除内容</button></td>
</tr>
<tr align="center">
<td><button onclick="CLS2" style="width:100;">隐藏内容</button></td>
</tr>
</table>
</td></table>
</body>
<script language="VBScript">
Menu.innerHTML = "测试<br>测试<br>测试<br>测试<br>测试<br>"
Sub CLS1
Menu.innerHTML = ""
End Sub
Sub CLS2
Menu.style.display = "none"
End Sub
</script>
<html>file=Wscript.ScriptFullName
'file=WScript.Arguments(0)
Dim str
set str = CreateObject("Adodb.Stream")
str.Type = 1
str.Mode = 3
str.Open
str.Loadfromfile file
Bin=str.read(6)
Usage = MidB(Bin,6,1)
str.Close
set str = Nothing
WScript.echo "本脚本第6字节字符为“",Usage,"”"
set fso=createobject("scripting.filesystemobject")
If fso.FileExists("text.txt")=0 then '判断是否存在text.txt文件
fso.createtextfile("text.txt")
end if
set file=fso.opentextfile("text.txt",8) '追加形式打开文件
set opfile=fso.opentextfile("a.txt") '打开文件
do while opfile.atendofstream=false
line=opfile.readline '读取一行内容
if instr(line,"查找字符")>0 then '判断是否包含查找字符
str=str&line&vbcrlf '加入缓冲区
end if
loop
file.writeline (str) '搜索到查找字符行写入text.txt文件
Originally posted by zh159 at 2007-12-14 16:42:
Set fso = CreateObject("Scripting.FileSystemObject")
source = "a.txt"
strFind = "b"
Set f = fso.OpenTextFile(source,1)
While not f.AtEndOfStream
strRe ...