Using Mac’s Automator to Make Diffing Easier

Recently I’ve been needing an easy way to paste two versions of a text, and get the differences between the texts, specifically changes within a line (most diff programs only show which lines have changed).  After some searching, DiffMerge came up as one of the best free diff programs that would work on the Mac.  DiffMerge is great in many aspects, however, it lacked the interface to paste in text to diff right off the start.

I set out using Mac’s Automator tool to create an application to prompt the user for two texts, create the temporary files, then pass it into DiffMerge.

AutomatorPasteDiffAutomator is a very easy to use visual scripting tool that you can use to create workflows that can be automated (hence the name).  Also, it comes with all Macs!  As great as Automator seems to be, there are some drawbacks: the actions aren’t too customizable, and the flow of data within the workflow is strictly “output” of one action to the “input” of the next.

I came up with the following workflow:

  1. Get value of a pseudo-variable – random identifier
  2. Set the value of the random identifier into a variable so the same identifier can be referenced later (subsequent steps refer to this value as just the “identifier”)
  3. Ask for base text
  4. Store base text in a temporary file (using the identifier as part of the filename)
  5. Ask for new text
  6. Store new text in a temporary file (using the identifier as part of the filename)
  7. Get value of the identifier
  8. Run a custom shell script to open up diffmerge with the files created in the steps above.  Passing in the identifier as an argument of the shell script allows us to figure out the name of the temporary files.  The shell script also removes the temporary files when DiffMerge is closed.

The result was quite successful.  Here is what DiffMerge looks like after pasting in two SQL dumps into the Automator application.  Notice the temporary filename.

PasteDiffI’ve uploaded the app to do this on my GitHub account.  It’s called “PasteDiff.app”.  You can download them, and open the apps in Automator in order to see precisely the actions used.

Many times, computers programs are born out of necessity to reduce repetitive or menial tasks.  For Mac users, Automator’s a nifty tool that can help with that.

If you have used Automator for anything cool, let me know in the comments!

Related

2 thoughts on “Using Mac’s Automator to Make Diffing Easier

  1. Yep, I use it at work quite regularly. Are you able to determine which step fails to work? For example, are the files being written correctly? Did you install the command line tool for DiffMerge?

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.