Compare Contents Of Two Folders

Compare Contents Of Two Folders

Compare Apples OrangesI am in the process of moving my paperless documents to a new location, and am taking that opportunity to clean up my folder structure a little bit.

After getting everything set up in the new location, I wanted a way of comparing the contents to the old directory tree to see if there are any glaring omissions/red flags.

Compare Folders On The Mac

I found this helpful Macworld article that shows how to compare two folders using the Terminal in Mac OS X. The command is diff.

In its simplest form, you type the command like this:

diff -rq firstfolder secondfolder

I wanted a way to exclude those annoying .DS_Store files that Mac OS X throws everywhere, so this was my command. Substitute your own folders, of course.

diff -rq -x .DS_Store ~/Desktop/Docs ~/Docs

Here is a sample result.

Diff Terminal Result

As you can see, it displays the result in a nice easy to read format.

If you have a lot of changes to view, you can redirect the results to a text file and check later at your leisure. To do that, change the command to something like this:

diff -rq -x .DS_Store ~/Desktop/Docs ~/Docs > diff.txt ; open diff.txt

Compare Folders On Windows

I did find a discussion thread with a way to compare folders using the Windows command line, but from my research it seems like many people use the open source tool called WinMerge. The latter allows you to do comparisons using a GUI.

If you have another way that you compare folders in Mac or Windows, please leave a comment and let us know how you do it.

(Photo by TheBusyBrain)

About the Author

Brooks Duncan helps individuals and small businesses go paperless. He's been an accountant, a software developer, a manager in a very large corporation, and has run DocumentSnap since 2008. You can find Brooks on Twitter at @documentsnap or @brooksduncan. Thanks for stopping by.

Leave a Reply 3 comments

Ashley - January 23, 2014 Reply

I’ve been using BeyondCompare by Scooter Software (http://www.scootersoftware.com/index.php) for a number of years. It’s now available for OSX, Linux, and PC. I started using it just to do folder comparison, but it actually does a great job of also doing simple backups and syncing. (You can set up defined comparisons (files or folders, etc), and then automatically have things merged or updated or just compared, based on the rules you set.)

It’s a GUI, so easier than command lines (for most). It can be overwhelming at first, but if you just focus on doing simple compares, it’s fine. (You can geek out and get all power-usery later. Or not.) (As a software engineer, I’ve been using grep and diff et al for a looong time. They have their place (they’re great for automating processes), but nothing beats a visual for being able to quickly see what’s different between things (something in *bright red* is gonna catch your eye!).

I use it to automatically compare and then copy updates/differences every day from my important folders (financial, legal, scans, ….) to a thumb drive.

It can compare files, zips, photos (graphic file formats);do 3-way comparisons, work with Dropbox, … pretty sweet.

NAYY. Just a long-time satisfied user.

Jeff - January 14, 2014 Reply

At my job I have to compare folders, and then decide which files need to go to which folder constantly.
I used to use the ‘diff’ command – but there came a point where the results were difficult to keep track of.
When this happened I looked for programs to do the comparing and syncing for me.

I tried a few programs but settled on DeltaWalker http://www.deltopia.com/compare-merge-sync/

It uses Java to run – but as a result it runs in Windows and Linux as well as the Mac.

I am only a happy customer of their product. And thought you’d like to know about it as well.

Regards,
Jeff

    Brooks Duncan - January 14, 2014 Reply

    Great, thanks Jeff!

Leave a Reply: