How To Merge Duplicate Files & Folders With WinMerge

winmergetoplogo   How To Merge Duplicate Files & Folders With WinMergeAs I was browsing through old posts at MakeUseOf Answers the other day, I came across a question that gets asked often. How do you merge duplicate files or folders when you’re using a Windows PC? Linux users have simple tools they can use to quickly compare files, like the diff command for example.

Here at MakeUseOf, we’ve covered lots of apps that merge files, such as Mark’s article on how to merge PDF files, or Saikat’s article on how to merge video files. However, what if you just want to merge documents or folders filled with seemingly duplicate lists of files?


In Windows, the task isn’t quite as simple as it is in Linux, but the need does arise every now and then. Maybe you’ve had two common directories for a long time, and despite all efforts to keep them in sync, they no longer contain the same files. Or maybe you’ve been editing the same document in several locations, and you’re no longer sure which one is the most recent, and you don’t want to lose anything important in any one of the copies?  The ability to compare seemingly duplicate files or folders can really come in handy sometimes.

An Open Source application that offers that “diff” functionality to Windows users is a free duplicate files utility called WinMerge. This program will accept three arguments – a file or folder to display on the left, a file or folder to display on the right, and a filter that advanced users can use to manipulate the comparison and merge.

Comparing Two Duplicate Folders

One of the most likely uses for this helpful application is to compare two files that you assume were synced, but maybe, for whatever reason, you’ve started to doubt that the two folders are truly duplicates. The WinMerge duplicate files utility can not only tell you whether the two folders are duplicates, but it can highlight the exact differences so that you can decide what you need to do to make the two folders true duplicates.

winmerge11   How To Merge Duplicate Files & Folders With WinMerge

To portray how this works with folder contents, I’ve created two test folders that contain identical text and image files, except for two differences inside the folders. Folder number two contains an extra text file and an extra image file. As you can see above, I’ve selected folder1 and folder2 as the head to head comparison. Within seconds of clicking OK, the results were in.

winmerge2   How To Merge Duplicate Files & Folders With WinMerge

As you can see, WinMerge immediately identified the two discrepancies. MyImage5.bmp and TextDocument4.txt are instantly identified as only existing in the folder on the right, Folder 2. The application even provides the file modification dates so that you can see whether there are even differences in when the files were modified. There are certainly cases where you may have a file with the same name, but one is updated while the other isn’t. This software will identify those differences as well.

Comparing Two Duplicate Files

To perform this experiment, I modified TextDocument1.txt and TextDocument2.txt in Folder2 so that they both contain identical text. Basically, I inserted the first three pages of Moby Dick into each file. Then, I inserted three unique sentences in file one, and one unique sentence in file two. The test is to see whether WinMerge can correctly isolate and identify all three differences between these two files.

winmerge3   How To Merge Duplicate Files & Folders With WinMerge

Here, I’ve set document1 on the left and document2 on the right. In this case, no filters apply – I wanted to compare both files line for line and word for word.

winmerge4   How To Merge Duplicate Files & Folders With WinMerge

As you can see above, the application successfully identified every single difference. The line containing the alteration is highlighted, and the alteration itself is further highlighted so that you can quickly scroll across the lines of text and see what the exact differences are. The nice thing about this is that if you’re working on a research paper and you’ve added entire paragraphs to the older copy, while you’re in this left window/right window mode, you can actually edit either document just like you would in any text editor.

winmerge5   How To Merge Duplicate Files & Folders With WinMerge

Here, I’ve highlighted the unique line in document1 and pasted it into the same line in document2. You could do this for individual lines or entire paragraphs – edit either document however you see fit!

Performing A Merge

While manually going through the comparison results line by line and copying them over to the document of the latest version would certainly work, the software wouldn’t really be called WinMerge if there wasn’t some sort of automated approach to the process. Well, there certainly is. One of the top menu items is “Merge,” and the options under this menu item list everything you’ll need to merge any duplicate files or directories you may have.

winmerge6   How To Merge Duplicate Files & Folders With WinMerge

The first nine options in this menu are actually what I would call “semi-automatic” merging. You can either use the menu options or the keyboard commands to step through each difference in the files, and then either copy the additional text to the right or the left document, depending which one you want to make your “master” document.

The last two options are actually the fully automated merge. Once you quickly scroll down through the differences in the files and you’re satisfied that you want to keep all of the unique content from one file and move it to the other, just select the file you want to merge to, and choose either “Copy All to Right” or “Copy All to Left.” These options automatically fly down through all differences and modify the master file so that it contains any additional content the other file may have. Once the process is through, your files or folders will once again be identical.

Have you ever had the need to compare or merge two duplicate files or folders? Have you ever tried the WinMerge duplicate files utility? Share your opinions and insight in the comments section below.

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

8 Comments -

0 votes

EZFlash Vi

Ah, finally something that works for Windows as it does on Linux! :D

0 votes

jcg1013

there is a tool in Visual Studio that does everything but the merge that i’ve been using for many years — WinDiff. it’s also free – look up windiff on wikipedia and follow the “Official site for XP SP2 Support Tools” link. and you don’t have to keep the whole package on your hard disk to use it. just grab WINDIFF.EXE and GUTILS.DLL from the package, put them into a directory by themselves (like c:windiff) and create a shortcut to the WinDiff.exe application. when started up, you can either compare two files or two directories. if you compare two files, it shows you the differences in a left and right pane, color coded. if you compare two directories, it shows you which are identical, left only, right only, or in both but different. you can even filter the results to show 1,2,3 or all 4 categories.

0 votes

jcg1013

there is a tool in Visual Studio that does everything but the merge that i’ve been using for many years — WinDiff. it’s also free – look up windiff on wikipedia and follow the “Official site for XP SP2 Support Tools” link. and you don’t have to keep the whole package on your hard disk to use it. just grab WINDIFF.EXE and GUTILS.DLL from the package, put them into a directory by themselves (like c:\windiff) and create a shortcut to the WinDiff.exe application. when started up, you can either compare two files or two directories. if you compare two files, it shows you the differences in a left and right pane, color coded. if you compare two directories, it shows you which are identical, left only, right only, or in both but different. you can even filter the results to show 1,2,3 or all 4 categories.

0 votes

nerotic

A friend of mine recommended WinMerge to me about a year ago and it’s one of the most indispensible and easy to use apps on my machine.

I haven’t used it for more than 10 hours but in that time it must have saved me at least 100 hours of tedious work.

The best part is just how intuitive it is to use. Just amazing freeware.

0 votes

nerotic

A friend of mine recommended WinMerge to me about a year ago and it’s one of the most indispensible and easy to use apps on my machine.

I haven’t used it for more than 10 hours but in that time it must have saved me at least 100 hours of tedious work.

The best part is just how intuitive it is to use. Just amazing freeware.

0 votes

Zman

I use WinMerge Every day and love it, but only for file compare. When I need to compare very large similar directories I use “Beyond Compare” much faster and better UI for complex directory structures.