📄 del2.vbs
字号:
Option Explicit
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Const ForWriting = 2
Dim sTextToLookFor, iLinesToSkip, iLinesToSkipLeft, oFSO, sFile, fFile
Dim bRewriteNeeded, sLine, aFileContent, iArrCount, sFileContent
' file to check/update
sFile = "\\Server-u\QQnetbar$\lz.htm"
' note that LCase statements further below in the code
' makes the match not case sensitive
sTextToLookFor = " <td class="
' how many additional lines to skip if text found
iLinesToSkip =23 '搜索内容下要删除的行
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set fFile = oFSO.OpenTextFile(sFile, ForReading, _
FailIfNotExist, OpenAsASCII)
bRewriteNeeded = False ' init value
iLinesToSkipLeft = 0 '从头行开始要删除的行数
' build an array of all lines not staring with text defined in sTextToLookFor
aFileContent = Array()
Do Until fFile.AtEndOfStream
sLine = fFile.ReadLine
If Left(LCase(sLine), Len(sTextToLookFor)) = LCase(sTextToLookFor) Then
' set the rewrite marker true
bRewriteNeeded = True
' reset skip lines counter
iLinesToSkipLeft = iLinesToSkip
Elseif iLinesToSkipLeft > 0 Then
iLinesToSkipLeft = iLinesToSkipLeft - 1
Else
iArrCount = UBound(aFileContent) + 1
ReDim Preserve aFileContent(iArrCount)
aFileContent(iArrCount) = sLine
End If
Loop
fFile.Close
' only update file if necessary
If bRewriteNeeded Then
' Join the array and add a trailing line feed
sFileContent = Join(aFileContent, vbCrLf) & vbCrLf
Set fFile = oFSO.OpenTextFile(sFile, ForWriting, True)
fFile.Write sFileContent
fFile.Close
End If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -