Reputation: 19
i have two text files- blacklist.txt and complete.txt. I want a batch file not bash file code. I want to delete the common lines between the two files. names in blacklist file should be deleted from complete.txt file any help ?
Upvotes: 2
Views: 401
Reputation:
This does Unicode input and output. Name it something.vbs.
Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set BlackFile = Fso.OpenTextFile(Arg(0), 1, False, -1)
Set CompleteFile = Fso.OpenTextFile(Arg(1), 1, False, -1)
Set OutputFile = Fso.CreateTextFile(Arg(2), True, True)
Set Dict = CreateObject("Scripting.Dictionary")
On Error Resume Next
Do Until BlackFile.AtEndOfStream
Line=BlackFile.readline
Dict.Add Line, ""
Loop
Do Until CompleteFile.AtEndOfStream
Line=CompleteFile.readline
If Dict.Exists(Line)
OutputFile.Writeline Line
End If
Loop
To use at command prompt.
C:\folder\something.vbs black.txt complete.txt newfile.txt
Upvotes: 1
Reputation: 79982
findstr /v /x /g:blacklist.txt complete.txt >outfile.txt
should remove all entries in blacklist
from complete
to produce outfile
Upvotes: 3