When several people are updating and making copies of the same files, multiple versions easily blossom out of control. Figuring out what’s changed, what hasn’t and merging it all back together can be a huge pain in the ass, but it doesn’t have to be. Say your kids downloaded images from the digital camera repeatedly to folders all over your hard drive. You and your co-worker lost track of who made the latest changes to that PowerPoint presentation. You want to merge the changes between two updated files into one. Fear not. The free, open source, WinMerge is a powerful utility that can help coders and civilians alike merge and compare data on their hard drives. Let’s take a look.Download WinMerge and get it installed on your PC (sorry Mac users.) Tick ‘Windows Explorer integration’ during installation – it comes in very handy later. At first glance WinMerge is a little intimidating – especially to non-coders – but it’s actually quite helpful once you make it your friend.
Compare and merge folder contents
You’ve got two directories of photos downloaded from the camera – some were cropped and de-redeyed, some weren’t, new photos were taken and old ones re-downloaded. Here’s how WinMerge can help. First, in Windows Explorer, select the two directories of photos (in this example, c:\photos\ and c:\pics\, and choose “WinMerge” from the context menu. You’ll get a file listing that displays all the files in both folders, which are identical and which exist on the “left” or “right” folder.
From the file listing, you can right-click on any entry to open (either version, where applicable) using your default application for the filetype. Or, you can copy files that exist on one side to the other using the “Copy Left” and “Copy Right” buttons in the toolbar (or key combinations Alt+Left Arrow and Alt+Right Arrow.)
Diff and merge text files
Not only can WinMerge detail differences in file listings, but it can also visually identify differences within files it can understand, like text files. Let’s take a look at the difference between the Windows Janitor script I posted last week versus an updated version a reader posted. (Click to enlarge image.)
In this three-pane interface, the left-most pane displays a map of the file differences. The orange areas indicate lines which differ, the grey areas show lines that exist in one file but not the other, and the white area shows identical lines in the file. Click on any one of those areas to skip directly to that section of the two files, which are shown in the two right panes. Using the toolbar buttons, you can merge all or selected changes from the left to right file.
Compare and merge office documents
Most non-programmers don’t work in text files, but WinMerge can also compare proprietary file formats, like Microsoft Office files. Supposedly WinMerge comes with Word and Excel support out of the box, but I had limited success getting that to work. If you too get the error message about WinMerge not being able to compare binary files, download and install the xdocdiff WinMerge plugin that diffs Word, Excel, PowerPoint, PDF, Outlook Email and RTF documents as well as OpenOffice.org and Lotus 1-2-3 files. The plugin installation isn’t one-click – be sure to extract the .zip file and copy the appropriate files into the WinMerge program folder as per the instructions on the plugin page.
Here’s what a comparison of 2 Lifehacker book chapter 3 drafts (Word documents) looks in WinMerge. (Click to enlarge.)
While WinMerge doesn’t display the files using Word itself, all the same text comparison features listed above apply: move all or selected changes left or right, and navigate the differences using the leftmost pane.
These three examples only cover WinMerge’s basic usage. Be sure to check out WinMerge’s online manual to roll up your sleeves and really get down and dirty with this useful utility.
How do you compare and merge files? Got any WinMerge pointers or questions? Hit us up in the comments.