怎么利用批处理替换文本文件中的指定内容 http://www.cn-dos.net/forum/view ... =%E6%9B%BF%E6%8D%A2作者: piziliu2004 时间: 2006-9-1 10:51 Function SearchFile(filespec)
Const ForReading = 1,ForWriting=2
Dim fso, theFile, retchar(80),i
i=0
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(filespec, ForReading, False)
Do While theFile.AtEndOfLine <> True
retchar(i) =theFile.Read(1)
i=i+1
Loop
Maxrow=i
theFile.Close
For i=0 To Maxrow
if retchar(i)="A" then
retchar(i)="D"
End If
if retchar(i)="B" then
retchar(i)="F"
End If
Next
Set theFile = fso.OpenTextFile(filespec, ForWriting, False)
For i=0 to Maxrow
theFile.write(retchar(i))
Next
End Function