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.
-
powershell script?– strange walkerNov 25, 2013 at 21:16
-
@strangewalker Is that available out of the box ?– happybuddhaNov 25, 2013 at 21:29
-
yep. though it may be difficult to write a script for someone without experience, its capabilities are almost limitless– strange walkerNov 25, 2013 at 21:34
-
If you willing to experiment with powershell, here's topic with similar question stackoverflow.com/questions/6526441/…– strange walkerNov 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– happybuddhaNov 25, 2013 at 21:56
6 Answers
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 :)
To compare content use:
compare-object (get-content a.text)(get-content b.txt)
and so on
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.
-
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
-
1Cygwin 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 :)– peterhNov 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 Nov 26, 2013 at 0:16
-
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.
-
dir /s /b
always displays the absolute path so every line will have a different path prefix which will causefc
to report every line. You will need a tool to strip the path prefix before the comparison. Nov 29, 2013 at 20:12 -
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.
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/...
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