How to compare two directories?

A

Anon E. Mouse

I've copied a large directory tree from my machine to an external disk.
I'd like to verify that everything copied accurately. How can I do that?

The "fc" command works well, but it doesn't have a switch that will do
subdirectories.

I'm thinking that some combination of the "for" command and fc will do
it, but the syntax of for is escaping me.
 
P

Pegasus [MVP]

Anon E. Mouse said:
I've copied a large directory tree from my machine to an external disk.
I'd like to verify that everything copied accurately. How can I do that?

The "fc" command works well, but it doesn't have a switch that will do
subdirectories.

I'm thinking that some combination of the "for" command and fc will do it,
but the syntax of for is escaping me.

Here you go:

@echo off
SetLocal EnableDelayedExpansion
set SourceDir=d:\logs
set TargetDir=e:\Test

for /F "delims=" %%a in ('dir /s /b "%SourceDir%"') do (
set Name=%%a
for %%b in ("!Name!") do (
echo fc "%%~db%%~pb%%~nb%%~xb" "%TargetDir%%%~pb%%~nb%%~xb"
)
)

Remove the word "echo" in the third line from the bottom to activate the
batch file.
 
A

Anon E. Mouse

Pegasus said:
Here you go:

@echo off
SetLocal EnableDelayedExpansion
set SourceDir=d:\logs
set TargetDir=e:\Test

for /F "delims=" %%a in ('dir /s /b "%SourceDir%"') do (
set Name=%%a
for %%b in ("!Name!") do (
echo fc "%%~db%%~pb%%~nb%%~xb" "%TargetDir%%%~pb%%~nb%%~xb"
)
)

Remove the word "echo" in the third line from the bottom to activate the
batch file.
Thank you. This is excellent. And posted in only 20 min!

Output is a bit verbose, so I have to pipe it to a file.
 
P

Pegasus [MVP]

Anon E. Mouse said:
Thank you. This is excellent. And posted in only 20 min!

Output is a bit verbose, so I have to pipe it to a file.

Thanks for the feedback.
 
T

Twayne

Anon E. Mouse said:
I've copied a large directory tree from my machine to an external
disk. I'd like to verify that everything copied accurately. How can I
do that?
The "fc" command works well, but it doesn't have a switch that will do
subdirectories.

I'm thinking that some combination of the "for" command and fc will do
it, but the syntax of for is escaping me.

Open 2 instances of Explorer and put them side by side.
 

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