Compare 2 directories in windows Compare 2 directories in windows windows windows

Compare 2 directories in windows


For Windows you can use this solution.

Here's the right way to do it, without the external downloads. It looks like a lot at first, but once you've done it, it's very easy.
It works in all Windows versions from 7 back to 95. For our example assume that you're comparing two directories named 'A' and 'B'.

  1. run cmd.exe to get a command prompt. (In Windows 7, the powershell won't work for this, FYI.) Then do it again, so that you have two of them open next to each other.
  2. in each window go to the directories that you want to compare. (Using 'cd' commands. If you're not comfortable with this, then you should probably go with the external utilities, unless you want to learn command prompt stuff.)
  3. type 'dir /b > A.txt' into one window and 'dir /b > B.txt' into the other. You'll now have two text files that list the contents of each directory. The /b flag means bare, which strips the directory listing down to file names only.
  4. move B.txt into the same folder as A.txt.
  5. type 'fc A.txt B.txt'. The command 'fc' means file compare. This will spit out a list of the differences between the two files, with an extra line of text above and below each difference, so you know where they are. For more options on how the output is formatted, type 'fc /?' at the prompt. You can also pipe the differences into another file by using something like 'fc A.txt B.txt > differences.txt'.

Have fun.


The following PowerShell code compares the file listings of two folders. It will detect renamed or newly created files and folders, but it will not detect modified data or different timestamps:

$dir1 = Get-ChildItem -Recurse -path C:\dir1$dir2 = Get-ChildItem -Recurse -path C:\dir2Compare-Object -ReferenceObject $dir1 -DifferenceObject $dir2

Source: MS Devblog - Dr. Scripto

3rd party edit

How to run a PowerShell script explains how to run the code above in a script.


We have been using Beyond Compare for years and it's quite useful. You can see which files are identical, which files are in folder "A" only and which files are in folder "B" only, and files that are different (for those files you can see what specific modifications have been made).