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. “get_dropbox_folder.sh” it just prints the dropbox folder, e.g. “/home/andrew/Dropbox”
  • if you run the script with a single argument of -v i.e. “get_dropbox_folder.sh -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.