You are not logged in.

#1 22 Jul 2014 13:16

platon39
Member
Registered: 24 Feb 2014
Posts: 30

batch script compare files and displays all the line with differences

Hello all,
i need an batch script that compares two files like :

file1.txt :
DE_MCC
DE_REAL
PL_REAL


file2.txt

PL_MCC    89
RO_MCC    64
RU_MCC    11
TR_MCC    77
UA_MCC    96
PL_REAL    87
RO_REAL    63
RU_REAL    1
TR_REAL    78
UA_REAL    97
RO_RHM    62
BE_MCC    86
CN_MCC    70
EG_MCC    94
ES_MCC    66
FR_MCC    67
HU_MCC    84
KZ_MCC    95
NL_MCC    85
PT_MCC    93
DE_REAL 1
DE_MCC  11


the result must be:
DE_MCC 1
DE_REAL 11
PL_REAL  87

i tryed findstr  but it didn't worked.

Thanks in advance for your help .

Offline

#2 22 Jul 2014 13:41

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: batch script compare files and displays all the line with differences

Try this: does it do what you need?

findstr /g:"file1.txt" "file2.txt"

Last edited by foxidrive (22 Jul 2014 14:49)

Offline

#3 22 Jul 2014 14:45

platon39
Member
Registered: 24 Feb 2014
Posts: 30

Re: batch script compare files and displays all the line with differences

Hi Foxydrive,
thanks and if i must put the output into file3.txt ?

Offline

#4 22 Jul 2014 14:48

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: batch script compare files and displays all the line with differences

findstr /g:"file1.txt" "file2.txt" > "file3.txt"

Last edited by foxidrive (22 Jul 2014 14:48)

Offline

#5 22 Jul 2014 14:51

platon39
Member
Registered: 24 Feb 2014
Posts: 30

Re: batch script compare files and displays all the line with differences

i tried like that and it didn't worked
FINDSTR: Cannot open file2.txt  > file3.txt

Offline

#6 22 Jul 2014 15:20

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: batch script compare files and displays all the line with differences

copy and paste it again.  Run it in the same folder as file1.txt and file2.txt

Offline

#7 22 Jul 2014 16:08

platon39
Member
Registered: 24 Feb 2014
Posts: 30

Re: batch script compare files and displays all the line with differences

i did it like that
but i get that error.
the files are in the same directory.
Does file3.txt need to be created first ?

Offline

#8 22 Jul 2014 16:51

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: batch script compare files and displays all the line with differences

No.  It works fine here.

Offline

#9 23 Jul 2014 06:08

Honguito98
Member
From: Mexico
Registered: 19 Sep 2013
Posts: 57

Re: batch script compare files and displays all the line with differences

foxidrive wrote:
findstr /g:"file1.txt" "file2.txt" > "file3.txt"

Try add ( and ):

(findstr /g:"file1.txt" "file2.txt") > "file3.txt"

.::{Honguito98}::.

Offline

#10 23 Jul 2014 08:14

platon39
Member
Registered: 24 Feb 2014
Posts: 30

Re: batch script compare files and displays all the line with differences

Hi ,
it worked with parantheses,thanks a lot!

Offline

Board footer

Powered by