Share the Knowledge!

A simple bash script containing a self-contained function called get_dropbox_folder which sets a global variable $DROPBOX_FOLDER which is the location of the user’s dropbox folder, as extracted from the dropbox config database. Useful for when your script wants to know the location of the dropbox folder, and the user has moved it to a non-default location! Tested on Linux and MacOS X.

Feel free to copy’n’paste and reuse this function in your own bash scripts 🙂

There’s usage examples at the bottom:

  • if you run the script with no arguments i.e. “” it just prints the dropbox folder, e.g. “/home/andrew/Dropbox”
  • if you run the script with a single argument of -v i.e. “ -v” it prints a bit more text, e.g. “Location of dropbox folder for ‘andrew’ is: ‘/home/andrew/Dropbox'”

“Install” instructions:

(The script will warn you if it can’t find any of the programs it relies on. The bulk of the logic of the script was borrowed from pyDropboxPath so it should work with all versions (0.7 / 0.8 / 1.0) of dropbox. The base64-decoding was borrowed from here. )

2011-11-25 – it’s now been updated to work with the 1.2.x/1.3.x versions of Dropbox too!
2011-12-11 – should now work on MacOS X too without any modification.

Share the Knowledge!

Helpful(0) Unhelpful(0)
  • On latest OSX you need to add “-noheader” to the SQLite calls, otherwise it prints some garbage apart from the value and it can’t be parsed as integer.

  • Lasse Steen Bohnstedt

    Running on Linux Mint 17 Qiana: I had to add a check for “$HOME/.dropbox/instance1/config.db” to get it to work (the new bit here is the “instance1/” part).
    I think a general script should probably loop through instances (if there are more than one), and do something sensible. But didn’t bother for now.