Home > Smart Tip, Windows > Compare two folders without any external Tools

Compare two folders without any external Tools

February 27, 2011 Leave a comment Go to comments

Scenario : You have a certain folder whose backup is on a separate drive. You want to know whether they are in sync or not i.e. both contain the same no.of files or not

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. Open run and type cmd to get a command prompt. 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.)

3. Now type ‘dir /b > A.txt‘ into the first window and ‘dir /b > B.txt‘ into the other(Note : Make sure that the two text files names are different).  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 and then 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 > changes.txt‘.

Note : I recommend this method only when you have two single folders to compare with no subdirectories. You can do a compare of subdirectories using the /s switch but it is likely to give you the below error.

File Difference Error

 

Advertisements
  1. Comeandgo
    February 27, 2011 at 10:54 pm

    This will really come in handy!!! TY…

  2. jelson
    February 28, 2011 at 3:43 am

    Very nice trick… Sometimes an “old school” approach is exactly what’s needed!

    • February 28, 2011 at 11:04 pm

      I couldn’t agree more with you!!

  3. Missygirl
    February 28, 2011 at 9:56 pm

    Really Useful…thank you!!!

  4. BeingMe
    March 2, 2011 at 10:10 pm

    Nice Tip. Will definitely be useful for powerusers like us..:)

  5. Muriel
    March 7, 2011 at 9:49 pm

    Nice Tip!!!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: