All your gdocs are belong to you

Google CL (command line)

So you want to backup all your bas[^H^H]3 google documents ? You may do it manually, but isn’t it more interesting to do it by code ?

GoogleCL has been around for a while, but it’s becoming more stable and interesting as time goes on. Let’s see how to install it first, since the documented way on INSTALL.txt is broken at the time of writing these lines.

Since both pip and easy_install fail for me while installing gdata-python-client, the underlying library, I just go the old-fashioned way:

<br /> hg clone https://gdata-python-client.googlecode.com/hg/ gdata-python-client<br /> cd gdata-python-client && sudo setup.py install<br />

If your environment is sane, that would install your libs under /usr/local, not having to worry about munging with $PYTHONPATH.

Then, for googlecl, well, surprise: “easy_install googlecl” will do the trick (ignore INSTALL.txt this time) :)

Now, issuing a simple (no wildcard “*” needed!):

$ google docs get
Please specify folder: 
Please specify title: 
Downloading GiTools to /home/romanvg/tmp/docs.txt/GiTools.ppt
Downloading (42) CasosUs to /home/romanvg/tmp/docs.txt/(42) CasosUs.txt
(...)

Will download all your documents :) It’s important that you leave the command run until its full completion, otherwise most of the documents (if not all) will not be written to disk. There’s another catch as well: watch out for error messages like the following:

[Errno 2] No such file or directory: '/home/romanvg/tmp/docs.txt/Placement / Keyword Report, Feb 15, 2010 4:29:01 PM Central European Time.xls'
Does your destination filename contain invalid characters?

So morale of the story: Keep your filenames short, lowercased and simple, the UNIX way or clutter your nifty code with error-handling :)