Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare 2 directories in windows

I need to compare 2 folders "A" and "B" and get the list of files and folders newly added or modified.

I tried using Winmerge software but it is not comparing the files present inside the internal folders(so i have to point to each internal folder manually and have to compare)

Is there any way to achieve this.

like image 520
user2369634 Avatar asked Oct 05 '13 19:10

user2369634


People also ask

Can you compare two folders in Windows?

Click on the “Select Files or Folders” tab in the far left, to start a new comparison. Each comparison you run opens in a new tab. To start a new comparison, click on the “Select Files or Folders” tab in the far left, change the targets and click “Compare” again.

How do I compare folders in Windows 11?

Press the Ctrl and O buttons at the same time or go to File>Open. Under 1st File or Folder, click Browse and select the file or folder. Do the same for the 2nd File or Folder. Click on Compare after both the files or folders are selected.

Can Notepad ++ compare folders?

By default Notepad++ doesn't have compare function. We can make it possible by easily installing a compare plugin after Notepad++ is installed.


1 Answers

The following PowerShell code compares the file listings of two folders. It will detect renamed or newly created files and folders, but it will not detect modified data or different timestamps:

$dir1 = Get-ChildItem -Recurse -path C:\dir1 $dir2 = Get-ChildItem -Recurse -path C:\dir2 Compare-Object -ReferenceObject $dir1 -DifferenceObject $dir2 

Source: MS Devblog - Dr. Scripto

3rd party edit

How to run a PowerShell script explains how to run the code above in a script.

like image 115
Kirill Yunussov Avatar answered Oct 05 '22 23:10

Kirill Yunussov