6

Is there an out of the box way to compare two folders in Windows 7? The comparison should show the differences in terms of subdirectory folders and subdirectory files.

8
  • powershell script? Nov 25, 2013 at 21:16
  • @strangewalker Is that available out of the box ? Nov 25, 2013 at 21:29
  • yep. though it may be difficult to write a script for someone without experience, its capabilities are almost limitless Nov 25, 2013 at 21:34
  • If you willing to experiment with powershell, here's topic with similar question stackoverflow.com/questions/6526441/… Nov 25, 2013 at 21:36
  • @strangewalker can you whip one ? Or do you know where these are available to be used by everyone ? Also you should make this into an answer. This helps and I will upvote Nov 25, 2013 at 21:56

6 Answers 6

14

I'm not a powershell pro, but this would give you which files and folders exist in one folder but not the other.

$test1 = get-childitem -path C:\Users\IrisDaniela\Documents\test1 -recurse
$test2 = get-childitem -path C:\Users\IrisDaniela\Documents\test2 -recurse
compare-object $test2 $test1 | Where {$_.SideIndicator -eq '=>'}

This gives:

InputObject                                                 SideIndicator
-----------                                                 -------------
test1a                                                      =>
test.txt                                                    =>

You can also leave out the filtering of course, and get:

$test1 = get-childitem -path C:\Users\IrisDaniela\Documents\test1 -recurse
$test2 = get-childitem -path C:\Users\IrisDaniela\Documents\test2 -recurse
compare-object $test2 $test1

InputObject                                                 SideIndicator
-----------                                                 -------------
test1a                                                      =>
test.txt                                                    =>
test2b                                                      <=

Dunno if this is what you are looking for, but maybe it gives you a start :)

The folders in the example The commands and result

To compare content use: compare-object (get-content a.text)(get-content b.txt) and so on

3

There is a good unix tool named diff, which you can install from cygwin. The command diff -urNw /path/to/dir1 /path/to/dir2 likely does what you want.

On win, there is a gui tool named beyondCompare.

4
  • Thank you for your reply. Is there anything OOTB available in windows 7 ? I cannot install anything on this computer am working on. Nov 25, 2013 at 21:29
  • 1
    Cygwin tools can you run without installation, too, although it needs a little work. If you have luck, there is the same situation with beyondcompare, too. The simplest solution is to install this at home, and copy their folders on a pendrive. Be sure you don't do sometjing against the local network regulation, I couldn't very long sleep well if you losed your job because my advices :)
    – peterh
    Nov 25, 2013 at 21:32
  • 1
    @happybuddha Download a differ such as WinDiff, WinMerge, or similar. Copy it to a share available to this machine over the network. Execute it from there. \\myserver\myshare\windiff.exe localfolder1 localfolder2
    – Mark Allen
    Nov 26, 2013 at 0:16
  • Here's another vote for BeyondCompare. Nov 26, 2013 at 3:43
2

You can make a batch file that creates two temporary text files that contain the directory structure, then compare those temp files with fc.

Something like (and adjust for preferences):

dir %1 /s /b /a /ong > temp1.txt
dir %2 /s /b /a /ong > temp2.txt
fc temp1.txt temp2.txt

The arguments for the dir command are: /s recurse into child folders /b don't show details, you could want to omit this maybe /ong sort by ascending name, directories first

Also, remember to adjust for possible spaces in the arguments

EDIT: as noted in the comments, we'll have to get rid of the directory prefix from the list-of-files text file. This can be done with a batch file such as:

@echo off
setlocal EnableDelayedExpansion

for /F "delims==" %%a in (%1) do @(
    set CURR_LINE=%%a
    @echo !CURR_LINE:~%2!
)

endlocal

used as unprefix text_file.txt prefix_length. So for example unprefix temp1.txt 5 will output the contents of temp1.txt without the first 5 characters of each line.

2
  • dir /s /b always displays the absolute path so every line will have a different path prefix which will cause fc to report every line. You will need a tool to strip the path prefix before the comparison. Nov 29, 2013 at 20:12
  • ah yes, you're absolutely right.
    – frozenkoi
    Nov 29, 2013 at 21:45
2

I use FreeCommander (a Norton Commander clone) to do this. It provides "Synchronize Folders" feature that allows to compare two folders and optionally synchronize them. The compare options include "By CRC", "By date", "By Content", Sub Folders and mane more. It is very powerful and has helped me many time to perfectly do the very same thing you asked.

Generally, FreeCommander is very powerful tool. the other feature that I use often is search withing files and folders.

1

Here's a cmd batch script which compares two directory trees by file/folder path and by file size - showing differences in the two directories (recursively):

Please see this answer:
https://superuser.com/questions/1407481/...

1

Winmerge

Compares folders too. From their website:

Folder Compare

  • Regular Expression based file filters allow excluding and including items
  • Fast compare using file sizes and dates
  • Compares one folder or includes all subfolders
  • Can show folder compare results in a tree-style view
  • 3-way Folder Comparison

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .