dim fso,file,path,filename,find,read,spt,str,cy,cystr,count
set fso=createobject("scripting.filesystemobject")
file="1.txt"
if instr(file,"\")>0 then
path=left(file,instrrev(file,"\")-1)
filename=mid(file,instrrev(file,"\")+1)
else
filename="new_"&file
end if
find="1234"
if fso.fileexists(file)=false then msgbox "文件不存在,请填写正确路径!",64,wscript.scriptname
read=fso.opentextfile(file).readall
if len(read)>0 and instr(read,find)>0 then
spt=split(read,vbcrlf)
count=-1
for each str in spt
if instr(str,find)=0 then
count=count+1
redim preserve cy(count)
cy(count)=str
end if
next
cystr=join(cy,vbcrlf)
else
msgbox "没有找到要搜索的字符!",64,wscript.scriptname
end if
if len(path)>0 then
fso.createtextfile(path&"\"&filename).write cystr
else
fso.createtextfile(filename).write cystr
end if
set fso=nothing
'保存为vbs类型文件
'楼上用外部程序会大大降低执行效率
'专业vbs/bat回答,手机写的,请采纳!
'vbs每秒能执行几十万次
'批处理只有一千不到,更何况用了外出程序以后那短暂的几十毫秒的等待时间
'只是说下两者区别,并不是说批处理一无是处。
'注意要用ctrl+c不要右键复制
@echo off
type 1.txt|find /v "1234">1.new
move /y 1.new 1.txt