What Is The Syntax For Comparing Files In Multiple Subfolders?

G

Guest

I'm trying to compare multiple files at once using the file compare utility
at the command prompt (fc /b e:\folder1\*.* f:\folder1\*.*).

I can not determine the correct syntax for comparing all of the files in
both folders because some of the files are located in subfolders.

Is it possible to compare all files -- including those in subfolders --
using the fc command?

Cheers,

~ Mark
 
P

Pegasus \(MVP\)

Mark M Morse said:
I'm trying to compare multiple files at once using the file compare utility
at the command prompt (fc /b e:\folder1\*.* f:\folder1\*.*).

I can not determine the correct syntax for comparing all of the files in
both folders because some of the files are located in subfolders.

Is it possible to compare all files -- including those in subfolders --
using the fc command?

Cheers,

~ Mark

You cannot do this with fc.exe by itself - it has no folder walking
capability.
Try this batch file instead. Do not retype it - use copy & paste instead!

@echo off
set Folder=Folder1
set DriveA=E:
set DriveB=F:

dir /s /b /ad "%DriveA%\%Folder%" > C:\dir.txt

for /F "tokens=*" %%* in (c:\dir.txt) do call :sub %%*
goto :eof

:Sub
set One=%*
set Two=%*
set Two=%DriveB%%Two:~2%
cd "%One%"
cd "%Two%"
fc %DriveA%*.* %DriveB%*.*
pause
 
D

dobey

Mark M Morse said:
I'm trying to compare multiple files at once using the file compare
utility
at the command prompt (fc /b e:\folder1\*.* f:\folder1\*.*).

I can not determine the correct syntax for comparing all of the files in
both folders because some of the files are located in subfolders.

Is it possible to compare all files -- including those in subfolders --
using the fc command?

Cheers,

~ Mark

There is a program called CDCheck that can be used to compare files on your
HDD with one written to a CD.
This can also be used to compare files in local directories.

Not what you asked, but probably easier to use.
Freeware. http://www.kvipu.com/CDCheck/helplink.php?helpfn=overview
 
G

Guest

Hi Pagasus:

Thanks for responding.

I ran your batch file. (I deleted the 'pause' command first because I did
not want to scroll through the results; Windows XP provides an audible system
beep if File Compare finds a discrepency.)

I notice that there are a lot of output lines which read 'FC: cannot open
E:*.* - No such file or folder', so I'm not sure if the batch file is
sufficient to allow File Compare to compare every file or not. I manually
checked the contents of c:\dir.TXT against the corresponding directory
structure in Windows Explorer, and the directory list in dir.TXT is correct.

Do you know why there are so many '… No such file or folder' warnings?

Also, I installed and ran the CDCheck application -- suggested by dobey in
this same thread. It does a binary comparison very fast, but it did not find
any errors. On the other hand, File Compare displays errors while your batch
file is running. Here's one for example:

Comparing files E:edb.log and F:edb.log
***** E:edb.log
┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌→┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌*┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌:┌┌┌Z
┌┌┌┌┌Ü┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌¬┌┌┌║┌┌┌┌┌┌┌┌┌╩┌┌┌┌┌┌┌┌┌┌┌]_ÆV◄
***** F:edb.log
┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌→┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌*┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌:┌┌┌Z
┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌Ü┌┌┌┌┌┌┌┌┌┌┌┌┌┌┌¬┌┌┌┌┌┌┌┌┌┌┌┌┌║┌┌┌╩┌┌
*****

However, if I manually compare only these two particular files using fc at a
command prompt, then File Compare reports that there are no differences
encountered.

Do you know why File Compare would only report this discrepancy while
running from your batch file?

At this point, I am still not confident that all of the files in the two
folders are identical.

~ Mark


:

{snipped}
 
G

Guest

Hi dobey:

Thanks for responding.

I'm evaluating the application that you suggested. You're right, it is very
fast and easy. I'm still trying to verify its accuracy because there's an
issue where it does not agree with the File Compare command bundled with
Windows XP. (See my reply to Pegasus' post if you would like more
information about the discrepancy.)

~ Mark


:

{snipped}>
 
P

Pegasus \(MVP\)

The CDCheck tool might perform a binary comparison whereas
fc.exe is designed for ASCII files, unless you use the /b switch.
Since CDCheck appears to meet your requirements there is
little point in working out why you get error messages when
using my batch file.


Mark M Morse said:
Hi Pagasus:

Thanks for responding.

I ran your batch file. (I deleted the 'pause' command first because I did
not want to scroll through the results; Windows XP provides an audible system
beep if File Compare finds a discrepency.)

I notice that there are a lot of output lines which read 'FC: cannot open
E:*.* - No such file or folder', so I'm not sure if the batch file is
sufficient to allow File Compare to compare every file or not. I manually
checked the contents of c:\dir.TXT against the corresponding directory
structure in Windows Explorer, and the directory list in dir.TXT is correct.

Do you know why there are so many '. No such file or folder' warnings?

Also, I installed and ran the CDCheck application -- suggested by dobey in
this same thread. It does a binary comparison very fast, but it did not find
any errors. On the other hand, File Compare displays errors while your batch
file is running. Here's one for example:

Comparing files E:edb.log and F:edb.log
***** E:edb.log
???????????????????????????????*???????????????:???Z
?????Ü???????????????¬?????????????????????????]_ÆV?
***** F:edb.log
???????????????????????????????*???????????????:???Z
???????????????Ü???????????????¬????????????????????
*****

However, if I manually compare only these two particular files using fc at a
command prompt, then File Compare reports that there are no differences
encountered.

Do you know why File Compare would only report this discrepancy while
running from your batch file?

At this point, I am still not confident that all of the files in the two
folders are identical.

~ Mark


:

{snipped}
@echo off
set Folder=Folder1
set DriveA=E:
set DriveB=F:

dir /s /b /ad "%DriveA%\%Folder%" > C:\dir.txt

for /F "tokens=*" %%* in (c:\dir.txt) do call :sub %%*
goto :eof

:Sub
set One=%*
set Two=%*
set Two=%DriveB%%Two:~2%
cd "%One%"
cd "%Two%"
fc %DriveA%*.* %DriveB%*.*
pause
 
G

Guest

Hello Pegasus:

I appreciate your response.

I cannot tell if CDCheck appears to meet my requirement. My requirement is
to be confident that two folders contain exactly the same data before I
delete one of them.

When different applications claim to perform the same function but provide
contradictory results, then I do not have confidence in any of them.

If I could get File Compare to compare every file in both folders and it
reported no differences between them, then I would have confidence based on
the fact that two different applications report the same result.

Clearly, I am not going to navigate to 4,571 subfolders to use File Compare
on the 23,113 files involved. I posted my question because I am hopeful that
there is a way to automate the process.

If your gut feeling about troubleshooting your method is that it's not worth
the time investment, then please let me know because I can grudgingly search
for other file comparing utilities.

According to their web site, CDCheck is a utility for the prevention,
detection, and recovery of damaged files on CD-ROMs -- with an emphasis on
error detection. It is not primarily designed for file comparisons.

~ Mark
 
P

Pegasus \(MVP\)

Debugging my batch file is not hard but it takes a little more
persistence than many other posters appear to have . . .

Before I make any suggestions about my batch file, there is
a need to get more clarity on your aim. The following questions
are relevant:
- Why do you need to compare two folder trees?
- What will you do if some files are different?
- What will you do if some files are missing in one tree?
- What will you do if some files are missing in the other tree?
- Have you considered just synchronising the two trees,
making sure that both trees contain a full set of the latest
versions of your files?

The last question is highly relevant: There are powerful tools
to do just this.
 
D

dobey

Mark M Morse said:
Hi dobey:

Thanks for responding.

I'm evaluating the application that you suggested. You're right, it is
very
fast and easy. I'm still trying to verify its accuracy because there's an
issue where it does not agree with the File Compare command bundled with
Windows XP. (See my reply to Pegasus' post if you would like more
information about the discrepancy.)

~ Mark

You could try it in combination with some hash checking software.

From the site http://www.beeblebrox.org/software.php
-
This is a Windows shell extension that adds a tab to the file properties
page. The new tab is called "File Hashes" and it displays the MD5, SHA1
hashes of the file's contents as well as the CRC-32. It also has a field
where you can paste in the text of a hash for comparison. This is useful for
when download sites display hashes of a file and you want to check the hash
after you download.
-
I've used both of these with no problems, quite handy when copying to
CD/DVD.
 
A

Ayush

Replied to [Mark M Morse]s message :
I'm trying to compare multiple files at once using the file compare utility
at the command prompt (fc /b e:\folder1\*.* f:\folder1\*.*).

I can not determine the correct syntax for comparing all of the files in
both folders because some of the files are located in subfolders.

Is it possible to compare all files -- including those in subfolders --
using the fc command?

Cheers,

~ Mark


Hi Mark,

Use WinMerge(Free and Great!). http://winmerge.org
It supports command line options :
WinMerge [/r] [/e] [/f filter] [/x] [/s] [/ul] [/ur] [/ub] [/wl] [/wr] [/minimize]
[/dl leftdesc] [/dr rightdesc] leftpath rightpath [outputpath]

/? displays the most commonly used parameters as help dialog.
/r tells WinMerge to compare folders recursively . Normally WinMerge does not compare
subfolder contents but does the "flat" compare showing the files in compared folders
and subfolders as separate items. Using /r tells WinMerge to compare all files in all
subfolders. When subfolders are included, only unique subfolders are visible as
separate items in compare results. Note that including subfolders can increase
compare time remarkably.
/e allows WinMerge to be closed with a single Esc keypress. This is useful when using
WinMerge as an external compare application. WinMerge can act like an dialog which is
easy and fast to close.
/f allows selecting filter used. Filter can be filemask like "*.h *.cpp" or name of
filefilter like "XML/HTML Devel". Quotation marks must be used if filter mask or name
contains spaces.
/x closes WinMerge after information dialog when files are identical. This parameter
is useful when WinMerge is used as an external compare application. It helps to
faster process and/or ignore files which don't have any differences.
/s enables single-instance behavior. If there is already WinMerge running new compare
is opened to that same instance. Depending on other settings (if multiple windows are
allowed) new compare is opened to existing or new window.
/ul tells WnMerge to not add left path to MRU. External applications should not add
paths to Open-dialog's MRU lists.
/ur tells WinMerge to not add right path to MRU. External applications should not add
paths to Open-dialog's MRU lists.
/ub tells WinMerge to not add both paths to MRU. External applications should not add
paths to Open-dialog's MRU lists.
/wl initially opens left side as read-only. Use this when you don't want to change
left-side items in compare.
/wr initially opens right side as read-only. Use this when you don't want to change
right-side items in compare.
/minimize starts WinMerge as minimized. This option can be used to start WinMerge
minimized for lenghty compares.
/dl adds a description for left side shown instead of folder / filename. This allows
showing version number or label for compared items. Like "Version 1.0" or "Work Copy".
/dr adds a description for right side shown instead of folder / filename. This allows
showing version number or label for compared items. Like "Version 1.0" or "Work Copy".
leftpath is the folder or filename to open on the left side.
rightpath is the folder or filename to open on the right side.
outputpath is an optional output folder where you want merged files to be saved.


Good Luck, Ayush.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top