Compare Multiple Files in Windows

Here is how you can compare multiple files in Windows to see their Differences using Command Prompt

One of the advantages of having a PC is the ability to have a ton of first-party as well as third-party utilities that can integrate directly with your operator system. Moreover, you can also design your own little utilities for specific tasks that can help you do pretty much everything and automate anything you want to.

If you know your way around a console-line interface, there are tons of built-in utilities that you can use to streamline and automate your workflow and make it incredibly fast to perform simple and basic task that would normally take a huge chunk of your time performing manual labour.

One particularly useful utility that we are covering today is a text-based utility inside Command Prompt that allows you to quickly compare files and their differences instantly.

How to Compare Files and Find Their Differences Using Command Prompt

Note: Your files could also be in different locations – you just need to know the exact file path – if you know that already, you can open and use command prompt from anywhere. Here, we will demonstrate both methods.

In this case, we have created two files called a.txt and b.txt and placed them both in a folder called text_files. We want to compare these two files to see their difference.

  1. Open Command Prompt and type the following command,
    comp C:\Users\reall\Downloads\temp\text_files\a.txt C:\Users\reall\Downloads\temp\text_files\b.txt

  2. Or, if you can navigate to the text_files folder from the Command Prompt, you can use the following command instead (without the path),
    comp a.txt b.txt

That‘s it. It should show the result of the comparison command, as shown in the screenshot below,

File a.txt Content

my name is abc
a
my name is abc

File a.txt Content

my name is abc
a
my name is abc

Since both the files have the same content, you see that it shows that the File compare OK which means that both have the same content.

If we change the content even by one character, it shows the error in file comparison, indicating that there is a difference between both the files. If we change more content, we can see an error for every character difference.

File a.txt Content

my name is abc
a
my name is abc

File a.txt Content

my name is abc
b
my name is abc


File a.txt Content

my name is abc
a
my name is abc

File a.txt Content

my name is def
b
my name is def

The comp command also offers a few parameters that you can use to see the exact detail about how one file differs from the other. Here is how you can use those,

File a.txt Content

my name is abc
a
my namy is abc

File a.txt Content

my name is abc
b
my namy is abc
  • comp a.txt b.txt /A
    

Shows differences in ASCII characters, as shown in the screenshot. This is a much more human-readable form.

  • comp a.txt b.txt /L
    

Shows the line numbers in which the content differs.

Here is the complete list of options that you can use,

Compares the contents of two files or sets of files.

COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]] [/M]
  • data1 Specifies location and name(s) of first file(s) to compare.
  • data2 Specifies location and name(s) of second files to compare.
  • /D Displays differences in decimal format.
  • /A Displays differences in ASCII characters.
  • /L Displays line numbers for differences.
  • /N=number Compares only the first specified number of lines in each file.
  • /C Disregards case of ASCII letters when comparing files.
  • /OFF[LINE] Do not skip files with offline attribute set.
  • /M Do not prompt for compare more files.

To compare sets of files, use wildcards in data1 and data2 parameters.