Category Archives: technical

never use diff again.

With the advent of CVS and Subversion, we sometimes forget how difficult manually merging files and file structures can be. In particular, I’ve often been bothered by Mac OS X’s “replace rather than supplement” behaviour when copying a folder with the same name as an existing folder into a location. For instance, if your Fuji camera produces the typical 100_FUJI folder on your flash card and you copy this to a directory on your drive, any subsequent copies of this folder to the same directory will completely erase the previous contents of the 100_FUJI folder at the destination. (I found this one out the hard way while in Yellowstone two years ago.)

Instead, the desired behavior is usually to replace any files that exist with the same name, but to leave alone files that have no direct counterpart in the copied directory. This can be accomplished by dragging the contents of the folder and the contents of all subfolders… but when you have many folders (in particular, many levels of subfolders), this can be a complete pain and take a great deal of time.

A solution many OS X users unknowingly have access to is called FileMerge. Another wonderful relic from the world of NeXTStep, it’s actually initially intended for something completely different from the situation described above: merging the differences between two text files, visually.

Screenshot:  FileMerge showing differences between two files.
FileMerge showing differences between two files.

Screenshot:  selecting which change to accept in the merged version in FileMerge.
A menu allows you to select which change to accept in the merged version.

Exciting, but probably nothing you haven’t seen before. However, things get a bit more interesting when you toss a directory into it.

Screenshot:  FileMerge showing the differences between the directories in italics and unchanged items in plain text.

You’ll soon see why this folder merging came in handy today.