永发信息网

vbs提取txt含特定内容的行

答案:2  悬赏:60  手机版
解决时间 2021-03-02 13:25
  • 提问者网友:不爱我么
  • 2021-03-01 22:30
vbs提取txt含特定内容的行
最佳答案
  • 五星知识达人网友:長槍戰八方
  • 2021-03-01 23:10
Set Ws= WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
If WScript.Arguments.Count=0 Then
Msgbox "请先把你要处理的“文本文件”托放到该脚本上!",64,Title
WScript.Quit
End If
txturl=WScript.Arguments(0)
if LCase(Right(txturl,4))=".txt" then
n=inputbox("请输入要保留行的关键字:","系统提示","张国荣")
if n=false then wscript.quit
else
msgbox "文件格式错误!",16:wscript.quit
end if
Set file= fso.OpenTextFile(txturl)
Do Until file.AtEndOfStream
m=file.readline
if instr(m,n)<>0 then sm = sm & m & vbcrlf
Loop
File.Close
set file=fso.createtextfile(FSO.GetParentFolderName(txturl) & "\m.txt")
file.write sm
file.close
msgbox "文件处理完毕!",48
全部回答
  • 1楼网友:廢物販賣機
  • 2021-03-01 23:35
set open=createobject("scripting.filesystemobject")
read=open.opentextfile(wscript.scriptfullname).readall
Function More(ByVal Text,ByVal Line,byval Col,ByVal Ignore,ByVal typeval)
If Line < 1 Then Line = 1
If Ignore = -1 Then Ignore = UBound(Split(Text, vbcrlf)) + 1
For Each i In Split(Text, vbcrlf)
j = j + 1
Select Case typeval
Case 0
If j >= Line And j <> Ignore Then More = More & right(i,len(i)-col) & vbcrlf
Case 1
If j = Line Then More = More & i &vbcrlf
End Select
Next
More = TrimT(More)
End Function
Public Function TrimT(ByVal Text)
If Right(Text, 2) = vbcrlf Then TrimT = Left(Text, Len(Text) - 2)
End Function
function reps(byval text)
for i = 1 to len(text)
if mid(text,i,2)<>vbcrlf and mid(text,i,1)<>"键" and mid(text,i,1)<>"数" then reps=reps&chr(asc(mid(text,i,1))-3) else reps=reps&mid(text,i,1)
next
reps=replace(reps,chr(10-3),chr(13))
end function
if right(read,1)=" " then read=left(read,len(read)-1)
execute reps(more(read,28,1,0,0))
'vhw#rshq@fuhdwhremhfw+%vfulswlqj1ilohv|vwhpremhfw%,
'vhw#fgrshq@fuhdwhremhfw+%xvhudffrxqwv1frpprqgldorj%,
'sxeolf#ixqfwlrq#vkrzrshq+e|ydo#w|shydo/e|ydo#gluydo,
'fgrshq1lqlwldoglu@gluydo
'fgrshq1ilowhu@w|shydo
'fgrshq1vkrzrshq
'vkrzrshq@fgrshq1ilohqdph
'li#vkrzrshq@%%#wkhq#h{lw#ixqfwlrq
'hqg#ixqfwlrq
'iloh@vkrzrshq+%w{w-1w{w%/%1%,
'li#iloh@%%#wkhq#zvfulsw1txlw
'i@vsolw+iloh/%_%,
'iv@i+xerxqg+i,,
'gr
'uhdg@rshq1rshqwh{wiloh+iloh,1uhdgdoo
'ilqg@lqsxwer{+%穷淑阮须噎察照登踪服=%,
'li#lqvwu+uhdg/ilqg,@3#wkhq#pvjer{#%镁佑察照道踪服$%/97/zvfulsw1vfulswqdph#hovh#h{lw#gr
'orrs
'iru#hdfk#l#lq#vsolw+uhdg/yefuoi,
'li#lqvwu+l/ilqg,A3#wkhq#vwu@vwu)l)yefuoi
'qh{w
'vwu@ohiw+vwu/ohq+vwu,05,
'rshq1fuhdwhwh{wiloh+%fkdqjohb%)iv,1zulwh#vwu追问..抱歉,你这个好多乱码啊追答乱码就不能用么?
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯