1. Home
  2. Windows Tips
  3. Compare folder content from command prompt on windows 10

How to compare folder content from the Command Prompt on Windows 10

If you need to compare files or folders, you’ll find there is no shortage of apps that can help you do the job. If you need to compare folder content from the Command Prompt, Windows 10 comes with a built-in tool called RoboCopy. It’s a Microsoft tool that comes bundled in Window 10 as of its recent versions. It’s a pretty useful tool that can compare folder content among other things. All you need to know is the correct command to run.

Compare folder contents

In order to compare folder contents, you need the complete path to the two folders that you want to compare. It’s easy enough to get. Open both folders in File Explorer and click inside the location bar. Copy the folder locations and paste it in the following command. Replace Path 1 and Path2 with the path to the two folders that you want to compare.

Syntax

robocopy Path1 Path2 /L /NJH /NJS /NP /NS

Example

robocopy "C:\Users\fatiw\Desktop\Test Folder 1" "C:\Users\fatiw\Desktop\Test Folder 2" /L /NJH /NJS /NP /NS

Understanding results

For the above command, the Command Prompt returned the following results. When you run this command on your system, the file names will be different however The *EXTRA File and the New File title will precede the files that RoboCopy finds. You need to understand the result in order find the difference between the two folders that you just compared.

*EXTRA File alex-1315367-unsplash.jpg
*EXTRA File beautiful-bloom-blooming-132474.jpg
*EXTRA File irina-iriser-1323394-unsplash.jpg
New File abstract.jpg
New File Clouds_minimalistic_binary_storage_2560x1600.jpg
New File Triangle_1920x1080.jpg

RoboCopy is showing you unique files found in the two folders that you compared. This means that all the files listed in the results are present on only one of the two folders that you compared.

The files that are preceded by *EXTRA Files are the files that are present in the second folder that you entered in the command. From the previous example, the files alex-1315367-unsplash.jpg, beautiful-bloom-blooming-132474.jpg, and irina-iriser-1323394-unsplash.jpg are present in Test Folder 2 and are NOT present in Test Folder 1.

It is then obvious that the file names preceded by New File are all files that are present in the first folder that you entered and are not present in the second folder. Again, continuing with the initial example, abstract.jpg, Clouds_minimalistic_binary_storage_2560x1600.jpg, and Triangle_1920x1080.jpg are all present in Test Folder 1 and are NOT present in Test Folder 2.

The command will not list the files that are common between the two folders.

If you’re having trouble figuring out the results, run the command on two dummy folders which only have a small number of files so that you can compare the results with the actual files in the folders and understand them.

Need a quick way to copy a file to multiple folders at once? There’s a little command that can do just that.

2 Comments