WENzER
WENzER

Reputation: 305

Comparing Folders and Subfolders files using batch command

I have two folders. I want to compare the files inside these folders.There are some subfolders in root folders. These sub folders are also containing some files. I want to compare these files in subfolder also. For that I am trying to write a batch file. Any kind of solution will help me a lot

Upvotes: 0

Views: 4661

Answers (2)

GoodOne
GoodOne

Reputation: 1

try dir /b /s

to search for files within subdirectory, instead of dir /b

Upvotes: 0

Marcos Placona
Marcos Placona

Reputation: 21730

I would not use a batch file at all to accomplish this task. BeyondCompare is here to do exactly that, and does it seemingly well.

Now on the other hand you really wanna do it via batch file, I'd suggest you install a tool called diff tools, and you'll be able to do something like:

diff.exe <file1> <file2> <htmlfile>

On the command line.

hope it helps

UPDATE As a follow up to your comment, I write this, which also seems to work for me, and doesn't use any external tool. This is a simple example, but you can make it better.

if exist compare.log del compare.log if exist missing.log del missing.log

for /f "delims=" %%a in ('dir/b/a-d c:\test\1') do (
    if exist "C:\test\2\%%a" (
        fc "c:\test\%%a" "C:\test1\%%a" >> compare.log
    ) else (
        echo %%a is missing >> missing.log
    )
)

Pause

Upvotes: 1

Related Questions