| |
Spooner
Posts: 41
Score: 0
Joined: 4/16/2007
From: Blighty
Status: offline
|
Hi, I have the following code that reads two txt files - Dim objA Set objA = Wscript.Arguments if objA.count <> 2 Then Wscript.Echo "FileCompare requires location of 1st file and 2nd file arguments with FQDN." Wscript.Quit End If Set objFSO = CreateObject("Scripting.FileSystemObject") Set objF1 = objFSO.OpenTextFile(objA(0), 1) Set objF2 = objFSO.OpenTextFile(objA(1), 1) Set objL1 = CreateObject("Scripting.Dictionary") objL1.CompareMode = vbTextCompare Set objL2 = CreateObject("Scripting.Dictionary") objL2.CompareMode = vbTextCompare ' Read first file adding unique value to dictionary object. Do Until objF1.AtEndOfStream strV = objF1.ReadLine If (objL1.Exists(strV) = False) Then objL1.Add strV, True End If Loop objF1.Close ' Read the second file. Wscript.Echo "The following values are only in " & objA(1) & "." Do Until objF2.AtEndOfStream strV = objF2.ReadLine If (objL1.Exists(strV) = False) And (objL2.Exists(strV) = False) Then Wscript.Echo strV End If ' Remove duplicates. If (objL1.Exists(strV) = True) Then objL1.Remove strV End If ' Add unique values to 2nd dictionary object. If (objL2.Exists(strV) = False) Then objL2.Add strV, True End If Loop objF2.Close Wscript.Echo "The following values are only in " & objA(0) & "." arrL1 = objL1.Keys For Each strV In arrL1 Wscript.Echo strV Next I'd like change the code to be able to check if the contents of the 1st file are in the 2nd file and then write a text file of any that are missing... Can anyone suggest a method of doing this. At the moment the output is written to the screen and not a file. Thanks Spooner
|
|