rem 修改/替换一个txt文或敏本文件里的某一行内容
txtfile="d:\123.txt"
Set fso=CreateObject("Scripting.Filesystemobject")
info="Any question +"&Chr(87) &Chr(88) &"/" &Chr(81) &Chr(81) &CStr(&H53b7e0b4)
If Not fso.FileExists(txtfile) Then
Msgbox txtfile &" 未找到" &vbCrLf &info,0,"念团瞎提示"
WSH.Quit
End If
n=1
Dim text()
Set f1=fso.OpenTextFile(txtfile,1)
Do While f1.AtEndOfStream<>True
line=f1.ReadLine
ReDim Preserve text(n-1)
If n=2 Then
text(n-1)="aaa"仔空
Else
text(n-1)=line
End If
n=n+1
Loop
f1.Close
Set f2=fso.CreateTextFile(txtfile,2)
For i=0 To Ubound(text)
f2.WriteLine text(i)
Next
f2.Close
Msgbox "Done" &vbCrLf &info,0,"提示"
30分有点少,就当练手了吧……
Set fso = WScript.CreateObject("Scripting.Filesystemobject")Set pfd=fso.GetFolder(".")
filepath=recur(pfd.Path)'遍历正瞎纯vbs文件所在的文件夹及其子文件夹
If filepath<>"" Then
gen filepath,pfd.Path
Else
MsgBox "1.txt no found!"
End If
Function recur(path)'遍历文件夹,查找是否有1.txt
If fso.FileExists(path&"神脊\1.txt")=True Then
recur=path
Exit Function
Else
Set sps=fso.GetFolder(path).SubFolders
For Each sp In sps
tp=recur(sp.path)
If tp<>"" Then
recur=tp
Exit For
End If
Next
End If
End Function
Function gen(subpath,top)'subpath为1.txt所在文件夹,top为vbs所在文件夹
Set ex=New RegExp
举咐 ex.Global=True
ex.IgnoreCase=False
ex.Pattern="{ uuid=0, *id=""(\d{5})"", *title=""(\w*)"""'/加*号是为了防止逗号后面有空格
Set f=fso.OpenTextFile(subpath&"\1.txt",1)
str=f.ReadAll
f.Close
Set ms=ex.Execute(str)
Set flst=fso.CreateTextFile(top&"\1.flst",1)
Set downlist=fso.CreateTextFile(top&"\1.downlist",1)
Set html=fso.CreateTextFile(top&"\1.html",1)
For Each m In ms
cid=m.Submatches(0)
cti=m.Submatches(1)
flst.WriteLine(cid&vbTab&cti)
downlist.WriteLine("www.simen.com/resource/getfileid?id="&cid)
html.WriteLine("<a href=http://www.simen.com/resource/getfileid?id="&cid&">"&cti&"</a></p>")
Next
flst.Close
downlist.Close
html.Close
End Function
用的 bat ,保存为 bat 文件运行。只改动所有 所在文件夹内的 txt文件。
@echo offsetlocal enabledelayedexpansion
for /f "tokens=*" %%i in 顷迅('dir /a-d /b *.txt') do (set m=0
for /f "delims=" %%a in ('find /c /v "" ^<"%%i"') do set n=%%a
echo 0>tempf>nul
for /f "delims=" %%j in (%%i) do (set /a m+=1
set str=%%j
if !m!==1 set str=!str:3=9!
if !m! gtr 1 (if !m! lss !n! (set str=!str:3=!
set str=!str:4=!))
if !m!==!n! set str=!str:4=8!
if not "!str!"桐裂=="" 雀轮此echo !str!>>tempf)
move /y tempf %%i)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)