batch to delete lines in text

May 13, 2009 at 00:19:36
Specs: Windows XP
Hi, i want to write a batch to do the following job. Now i have a.txt and b.txt. a.txt contains the information like:
List1 Error SimulationError a
List2 Error SimulationError b
List3 Error SimulationError c
List4 Error SimulationError d
and b.txt contains information like:
List4 Error SimulationError d
The batch will scan a.txt and b.txt, and then delete those lines which contains certain line from b.txt and.
anyone can give a help? thanks

See More: batch to delete lines in text

Report •

May 13, 2009 at 00:21:23
add: the output file will contain the following:
List2 Error SimulationError b
List3 Error SimulationError c

Report •

May 13, 2009 at 01:19:52
it's also fine to use vbs .i know how to do it in vb, can anyone help me to convert it to vbs.
Imports System
Imports System.IO
Module Module1

Sub Main(ByVal args() As String)
Dim f As New FileInfo(args(0).ToString)
Dim s As String() = File.ReadAllLines(f.FullName, System.Text.Encoding.Unicode)

Dim e As New FileInfo(args(1).ToString)
Dim t As String() = File.ReadAllLines(e.FullName, System.Text.Encoding.Unicode)

Dim linenumber As Integer = 0
Dim warnings As New ArrayList
Dim errors As New ArrayList

Dim content As String
Dim contentExc As String
Dim i As Integer = 0
Dim j As Integer = 0
Dim counter As Integer = 0
While i < s.Length
content = s(i)
j = 0
While j < t.Length
contentExc = t(j)
If content.Trim.Contains(contentExc.Trim) Then
GoTo Ignore
End If
j += 1
End While

If content.Contains("WARNING") Then warnings.Add(content)
If content.Contains("ERROR") Then errors.Add(content)
i += 1
End While

Using out As New StreamWriter(f.FullName & "_full", True)


i = UBound(args)
If i <> 0 Then
out.WriteLine("The file contains the excepted can be found at \\inventor\Main\Setups\Install\Tools\MSIVAL2")
End If

out.WriteLine("ERRORS: " & errors.Count)
out.WriteLine("WARNINGS: " & warnings.Count)

If errors.Count = 0 Then
GoTo NoError 'since no error is detected, no need to display "first 10 errors"
End If
out.WriteLine("First 10 errors:")

j = 0
Dim err As String
For Each err In errors
j += 1
If j > 9 Then Exit For

End Using

Catch ex As Exception
Console.WriteLine("Exception caught in FormatMail - " & ex.Message & " - You must provide a full path file name")
End Try
End Sub

End Module

Report •

May 13, 2009 at 02:41:14
if you can afford to use other languages, such as Python, here's an alternative solution
print set(data1).difference(data2)

Report •

Related Solutions

Ask Question