Export Dropbox

Export Dropbox

Published on Apr 7, 2018, 7:00 AM1 min read

(I found this old post, I don't know if I ever finished it, but figured its worth sharing)

I found this cool little golang utility to work with dropbox called dbxcli. Download a recent release from the releases tab.

dbxcli account

Follow the onscreen instructions to pair to your account.

Then comes the fun bashy magic.

First we need to pick a directory to export to. I used $HOME/Dropbox

mkdir $HOME/Dropbox

Now goto that directory

cd $HOME/Dropbox

Export a list of all files

dbxcli ls -R -l > files.txt

Create all the directories that are needed

grep -- "-             -        -" ../files.txt | cut -c38- | perl -pi -e 's/  //g' | while read DIR; do mkdir -p "$PWD$DIR"; done

The first grep grabs anything with the 3 dashes, which seems to be how directories are listed. Strip out that chunk with cut, and remove all the extra spaces with perl then finally read each line and make the directory

grep -v -- "-             -        -" ../files.txt | tr '\t' ' ' | cut -c38- | perl -pi -e 's/  +//' | while read FILE; do dbxcli get "$FILE" "$PWD$FILE"; done

Same as above, but filter out only the hyphenated rows, leave everything else. Then tell dbxcli to grab those files.

And we wait for a while

Gavin Mogan
Burnaby, BC, Canada

I'm Gavin.

I'm a tinker, maker, and software developer.

At home I code, game, hang out, all the cool non robot things to do.

Heavily involved with Jenkins open source, and will often submit PRs to random other projects.

I also play games, both board and video games and love to read.

You can usually find me on various services as halkeye.