Share the Knowledge!

A little bash script which uses the curl (or wget) and diff (and sqlite3) programs to download the ‘previous’ version of a file from Dropbox, and diff it to the current version of the file (the one on your computer).

  1. Download it from http://dl.dropbox.com/u/340607/dropdiff.sh
  2. Copy it to somewhere in your $PATH
  3. Make it executable
  4. Call it with the (full or relative) path to a file in your local dropbox folder, e.g.
dropdiff.sh "~/Dropbox/Some/Edited File"

If there’s not at least two versions in the file’s “revisions list” (i.e. the last edit was longer than 30 days ago) then the script will spot that and tell you. As it uses the ‘diff’ command line tool it can only compare text files.

This ‘screen-scrapes’ the dropbox website, so will probably break if the dropbox website changes

Updated 2010-10-08 – it now uses `readlink` so it can cope with relative paths and symlinks, and it uses my Get Dropbox Folder function to automatically determine the dropbox folder location.

Updated 2010-12-22 – it now uses real_path from http://sites.google.com/site/jdisnard/realpath since ‘readlink -f’ is non-portable. Thanks  ..alex.. and Eliphas Q.

Updated 2011-05-04 – it now interactively-prompts for the dropbox username and password (so they’re not stored in the script), it now actually checks the login details are correct 🙂 and there’s an option to automatically delete the login cookie when the script finishes. Thanks for the code & suggestions from Juan Carlos Chak.

Updated 2011-05-12 – lots of changes! Added command-line arguments and a proper usage message. Username and password can be specified in the script, on the command line, or entered interactively. Managed to get rid of mktemp so that it’ll work on MacOSX. Entire script can now use either curl or wget. Fixed small path-handling bug.

If you’d like to see diff functionality baked-in to Dropbox itself, make some noise here: https://www.dropbox.com/votebox/141/version-diff-ing-in-the-web-client-

Share the Knowledge!

Helpful(0) Unhelpful(0)