Report lines NOT in two compared files - TechRepublic
General discussion
February 2, 2006 at 04:34 PM
cornejo.alvaro

Report lines NOT in two compared files

by cornejo.alvaro . Updated 20 years, 5 months ago

Hi

I’m quite new on this and I need to compare 2 text files that contains several lines and get a report of wich lines are NOT in both files. I’ve made a vbscript and can get to have wich lines are in both files; however I can’t get to make it work for the ones that are not.

I can not just use the negative of the compare since other wise I’ll have a entry for each of line that does not match each line on the first file

This is what I got

FUNCTION Compare
SET f1 = fs.OpenTextFile(TxtFile1, FORREADING)
SET rf = fs.OpenTextFile(ResultFile,FORWRITING,TRUE)
SET OrigLine = Nothing
SET CmpLine = Nothing

DO
SET f2 = fs.OpenTextFile(TxtFile2, FORREADING)
OrigLine = f1.Readline
DO UNTIL f2.AtEndOfStream
CmpLine = f2.Readline
IF OrigLine = CmpLine Then
rf.WriteLine OrigLine
END IF
LOOP
f2.Close
LOOP UNTIL f1.AtEndOfStream
rf.Close
f1.Close
END FUNCTION

Any ideas?

Regards

Alvaro

This discussion is locked

All Comments