How do I compare two directories on cmd prompt of Windows m/c? I want equivalent of diff -r of UNIX.
Install Cygwin and you can use diff -r
on Windows.
To compare data with command prompt you can use
COMP /a /l D:\Folder1\data.txt D:\Folder2\data.txt
There can be different options like specific numbers of lines to search and case insensitive search and even you can compare folders with command prompt. Here are other options to compare files and folders with command prompt.
A partial solution (and thus for me unfortunately a "non-solution", although I had high hopes for it initially), which may or may not be enough for you:
It seems the ROBOCOPY tool can be (ab-)used to work as a kinda poor man's recursive comparison; with the unfortunate limitation, that it apparently doesn't compare file contents. It seems to compare sizes, dates and optionally attributes. The magic incantation for this would be:
ROBOCOPY path1 path2 /e /l /ns /njs /njh /ndl /fp /log:result.txt /it
where options meaning seems to be:
/e
- recurse, including empty directories;/l
- only print a log, don't modify files;/ns /njs /njh
- don't print file sizes, job summary, job header;/ndl
- "don't log folder names"
/log:result.txt
- write results to 'result.txt' file; I think this can be omitted and result will be shown on standard output then.Additional options:
/it
- I think this should be added if you want to compare attributes too - see an explanation on what "tweaked" files are.As I said above, this seems not to compare file contents, unfortunately. I verified this by running the following command first:
mkdir d1\a\b d2\a\b & echo x > d1\a\b\f & echo y > d2\a\b\f
Most of the time, this should produce files d1\a\b\f and d2\a\b\f with same timestamps, you can verify with dir d1\a\b\f d2\a\b\f
. The robocopy
call on d1 & d2 produced an empty result set for me.
In Windows there is the fc
command. I think diff
is way better, but if you want to use only what came with the installation, well, here you go! :)
You can install Gow, and you can run diff in the Windows Command Prompt.
You can use windiff util included in Windows from NT version and up. Just run 'windiff' and a graphic tool will pop up.
File -> Compare directories
http://msdn.microsoft.com/en-us/library/aa266122(VS.60).aspx
This article describes how to use it from command line. Great benefit of this tool is that it is already included and you don't need to download and install anything.