Thursday, January 8, 2015

How to Check if Two Files are Identical in Windows Using Command Prompt

There are different third party tools available over the internet to check if the two files are identical or not. But, Here I am going to explain a process to check if the files you have are same or not. You can use FC (File Compare) command to compare files natively in windows.

FC Command prompt


fc [/a] [/b] [/c] [/l] [/lbn] [/n] [/t] [/u] [/w] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2

/a : Displays only first and last line for each set of difference.

/b: To perform binary comparison.

/c: Use this switch if you want case insensitive comparison.

/l: Use this switch to compare files in ASCII format.

/lbn: Replace n with number to set the number of lines for the internal line buffer. The default length of the line buffer is 100 lines.

/n: Use this switch to display line number during an ASCII comparison.

/t: This switch will tell FC not to treat tabs as spaces.

/u: Use this switch to compare files in Unicode format.

/w: Use this switch to compress tabs and white spaces during comparison. If the line contains many consecutive tabs and spaces then FC will treat those white spaces and tabs as single white space if you use /w switch with FC.

/nnnn: Specifies the number of consecutive lines that must match before fc considers the files to be resynchronized. If the number of matching lines in the files is less than nnnn, fc displays the matching lines as differences. The default value is 2.


1. Two text file with different content.

File 1

File 2

2. Open command prompt and compare these two file using fc command. Here are the result when I executes the command.


In the above result the line having difference shown in the result as they do not match. You can try with multiple number of lines and you will see the line having difference prints on the command prompt console.

Let’s try with files having same content, type and size but different case. I will use /c switch to ignore the cases. Here are the two text file which I am going to compare.

File a

File b

In the above two text file the only difference is the text having first letter caps in words File and Compare. Here are the results.

Result without /c switch.

Output 1

Result with /c switch.

Output 2

FC command can only be applied to the files which are locally located. It will not work if we compare two files available on two different computers connected over LAN. To compare two files available on two different computers we can apply checksum process by using fciv tool. This is a Microsoft tool and can be downloaded free of cost. To read the step by step process of fciv please follow the below link.

Find duplicate files in a computer using md5 checksum.

1 comment: