Due to a series of technical snafus with Dropbox and Simplenote syncing, my main writing folder, which contains text files mostly in Markdown format, is all messed up.

I have about 500 unique files, but now each of them has multiple versions. For any given file, the directory contains something like this:


They mostly have identical content - some contain extra line breaks at the beginning, or a line containing the file name.

I didn't realize immediately that this had happened and that I had multiple versions, though, so with for some of them, though, I've modified one of the versions and not others. (The good news is that when I modify files, I don't edit or delete, I just add new text.)

I want to reconcile my folder so that I have one canonical version for each file.

Since there are now thousands of files, and more than two versions of each one, I'd rather not use a manual diffs app to reconcile them.

Is there a tool that will find multiple text files containing the same content and automatically merge them? Again, the files contain duplicated content, with some new content, so simply merging the duplicated content and then adding the new content at the end of the file would be satisfactory.

(I'm using OSX 10.8.2 and I write primarily in Aquamacs Emacs. Oh, and I'm going to stop using Simplenote.)


Since Mac is Unix based I am guessing it supports sdiff and cat commands on its terminals. I just wanted to post a comment here but since I don't have enough rep I am replying as an answer. So I guess we should try to do something like:

 loop a
     loop b
     if (sdiff fileA FileB*)==0 then cat fileA fileB*
     end loop b
 end loop a

Where we are just looping over every possible file that exists in the directory. I guess others users can tell us whether this is even possible or not!

  • +1 for the concept. I'd suggest writing a script like this. Test it out in a copy of the directory first, though. – corvec Feb 12 '13 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.