compare two files

April 16, 2010 at 13:41:57
Specs: Windows XP
Hi all,

I want to batch script to compare two text files and get the
difference in another file

Here is the example

log1.txt
C:\build_areas\bidi.h
C:\build_areas\chariter.h
C:\build_areas\convert.h
C:\build_areas\docmain.h
C:\build_areas\locid.h
C:\build_areas\normlzr.h
C:\build_areas\platform.h
C:\build_areas\pmacos.h
C:\build_areas\pos2.h
C:\build_areas\pos400.h
C:\build_areas\putil.h
C:\build_areas\pwin32.h
C:\build_areas\rep.h
C:\build_areas\resbund.h

log2.txt
C:\build_areas\bidi.h
C:\build_areas\chariter.h
C:\build_arease\convert.h
C:\build_areas\docmain.h
C:\build_areas\locid.h
C:\build_areas\normlzr.h
C:\build_areas\platform.h
C:\build_areas\pmacos.h
C:\build_areas\pos2.h
C:\build_areas\pos400.h

out put file should have the non-unique records.

diff.txt
C:\build_areas\putil.h
C:\build_areas\pwin32.h
C:\build_areas\rep.h
C:\build_areas\resbund.h


Thanks.


See More: compare two files

Report •


#1
April 16, 2010 at 14:06:53
you said "non-unique" but your sample had the unique records.
Also, is it known that one file is a subset of another? If fileA is a subset of fileB, you only have to do one pass, otherwise you have to do A against B then backwards B against A.

Report •

#2
April 16, 2010 at 14:14:26
Hi nbrane,

Thanks for responding quickly,

I want only one way, A against B because, yeah A is subset
of B, so you will see new files in A only.

I want to compare A against B and get non-unique records
from A.

Thanks.


Report •

#3
April 16, 2010 at 20:51:41
this should work, if i have my files in the correct places (it gets confusing! actually, i don't think it makes a difference...)
findstr /i /x /g:fileA.txt fileB.txt > diff

Report •

Related Solutions

#4
April 19, 2010 at 02:22:16
comp /?
sort /?

Report •

#5
April 19, 2010 at 08:25:33
Hi all thanks for the help,

it solved my problem using the
FC /c log1.txt log2.txt > FClog.txt
this is the out put it gave

Comparing files log2.txt and log1.txt
***** log2.txt
C:\build_areas\putil.h
C:\build_areas\pwin32.h
C:\build_areas\rep.h
C:\build_areas\resbund.h
***** log1.TXT
*****
but one more problem, i want to elimate these 3 lines from
the output file
Comparing files log2.txt and log1.txt
***** log2.txt
***** log1.txt

i want as
C:\build_areas\putil.h
C:\build_areas\pwin32.h
C:\build_areas\rep.h
C:\build_areas\resbund.h

can you please tell me how to remove those 3 verbose lines
or any
batch script ,

because i am going to give the Fclog.txt as input to some
other batch command which copies those files.

Thanks.


Report •

#6
April 19, 2010 at 09:56:36
FC /c log1.txt log2.txt | find /v "***** " | find /v /i "comparing files "> FClog.txt

findstr could also be used, with somewhat more accuracy:
FC /c log1.txt log2.txt | findstr /L /v /i /b "***** comparing files"> FClog.txt



Report •

#7
April 19, 2010 at 10:18:09
thanks nbrane

that worked.



Report •

Ask Question