我有一个任务是读取一堆记事本文件,在每个文件中,我需要删除字符串“动态”和“结束动态”之间存在的一组行,并删除这两个字符串同样。
附图显示了该文本文件中需要删除的部分,无论它发生在何处(动态结束动态 - 任何内容都可以与这两个边界一起出现)。
L3.3
resizeText 1
zoomLines 0
zoomArrows 0
doLasso 1
opaqueMove 1
selectDistance 30
adjustFonts 1
doubleBuffer 1
clipping 1
nCopyAreas 0
drawTextLimit 0.5
saveObjects 1
canvasBackground #050048007800
defaultForeground #000000000000
layers 1
layerName 0 0
layerName 1 1
layerName 2 2
layerName 3 3
layerName 4 4
layerName 5 5
layerName 6 6
layerName 7 7
layerName 8 8
layerName 9 9
layerName 10 10
layerName 11 11
layerName 12 12
layerName 13 13
layerName 14 14
layerName 15 15
layerName 16 16
layerName 17 17
layerName 18 18
layerName 19 19
layerName 20 20
layerName 21 21
layerName 22 22
layerName 23 23
layerName 24 24
layerName 25 25
layerName 26 26
layerName 27 27
layerName 28 28
layerName 29 29
layerName 30 30
layerName 31 31
gend
N 0
P 0 0
T -1
R 0 0
0
0 4 1 0
Name #WVP
0 1 1
!
27e
054878
-1-1-1
0
0
0
0 0
dynamics
script
//***GblSymDetails***
;DTLS; GSA_TEXT = "CIUXX"
//***ApplReplace***
//GEMTool = 1
// = ASPECTLINK
end script
end dynamics
0 0 1920 1080 0 0
N 2
P 34.7792 181.549
T 2 21071 1 0 0
0 0
R 0 0
0
0 0 3 0
Name STAT5495
0 1 1
!
27e
a5a5a5
a5a5a5
0
0
0
2 0
0 0 0
0 0 0 0 1
4
0 12.7627
11.5724 0
192.874 0.255264
185.159 12.3798
N 4
P 221.604 181.887
T 2 21071 1 0 0
0 0
R 0 0
0
0 0 5 0
Name STAT5496
0 1 1
!
27e
7c7c7c
7c7c7c
0
0
0
2 0
dynamics
script
func ip_FillColor() {
return FILLCOLOR;
}
func ip_LineColor() {
return LINECOLOR;
}
func ip_TEXT() {
return TEXT;
}
func BackColor() {
return RGB(124,124,124);
}
func ForeColor() {
return RGB(124,124,124);
}
// when ...
object.background = BackColor();
object.foreground = ForeColor();
end script
end dynamics
0 0 0
0 0 0 0 1
4
0 11.6149
6.04944 0
6.04944 54.445
0 72.5933
N 6
P 81.7124 181.888
T 2 21071 1 0 0
0 0
R 0 0
0
0 0 7 0
Name STAT5497
0 1 1
!
27e
616161
616161
0
0
0
2 0
dynamics
script
func ip_FillColor() {
return FILLCOLOR;
}
func ip_LineColor() {
return LINECOLOR;
}
func ip_TEXT() {
return TEXT;
}
func BackColor() {
return RGB(97,97,97);
}
func ForeColor() {
return RGB(97,97,97);
}
// when ...
object.background = BackColor();
object.foreground = ForeColor();
end script
end dynamics
0 1 0
0 0 0 0 1
72
93.8536 5.86588
答案 0 :(得分:0)
类似下面的代码。您应该能够添加代码以将所有文件转储到文件夹中,并通过DIR读取,剥离文本并自动保存输出文件。根据文件的数量,它可能会或可能没有时间效率。
Sub cleantext()
Dim lineOfText As String
Dim skipLines As Boolean
'Open files for writing
Open "D:\inputfile.txt" For Input As #1
Open "D:\outputfile.txt" For Output As #2
skipLine = False
Do Until EOF(1)
Line Input #1, lineOfText
If lineOfText = "dynamics" Then skipLines = True
If lineOfText = "end dynamics" Then skipLines = False
If Not skipLines And Not lineOfText = "end dynamics" Then Print #2, lineOfText
Loop
Close #1
Close #2
End Sub