Код:
![Выделить весь код](images/misc/selectcode.png)
Option Explicit
Dim oFolderItems, oFolderItem, sCont
Set oFolderItems = CreateObject("Shell.Application").NameSpace("C:\Test\nc\").Items
oFolderItems.Filter 64 + 128, "*.nc"
For Each oFolderItem In oFolderItems
Do
With CreateObject("Scripting.FileSystemObject").OpenTextFile(oFolderItem.Path, 1, False)
If .AtEndOfStream Then Exit Do
sCont = .ReadAll
.Close
End With
With CreateObject("VBScript.RegExp")
.Global = True
.MultiLine = True
.IgnoreCase = True
.Pattern = "(Pressorting[\s\S]*?)$"
sCont = .Replace(sCont, "$1" & vbCrLf & "f5000")
End With
With CreateObject("Scripting.FileSystemObject").OpenTextFile(oFolderItem.Path, 2, True)
.Write(sCont)
.Close
End With
Loop Until True
Next