Saturday, September 05, 2009

Batch upload documents to Google Docs

Recently, I started to use Google Docs service quite often to work with documents and store full texts of papers in PDF. Unfortunately, it's not possible to upload multiple files at once using the web-interface. It might appear to be pretty tedious to upload a hundred documents in this way. But several days ago the ability to upload PDFs has been added to Google Data API. So I decided to make a simple Java tool to utilize this feature.

All you need is to provide path to a directory containing files to upload and your login / password for a Google account. It will recursively traverse subdirectories and upload all files. The following file formats are supported: csv, doc, docx, html, htm, ods, odt, pdf, ppt, pps, rtf, sxw, tsv, tab, txt, xls, xlsx. To use the application you need Java 1.6 or higher installed. If you don't have it, download here:

There are several ways to use the program:

  1. java -jar google-docs-upload.jar

    In this case you will be prompted to enter your login / password and path.

  2. java -jar google-docs-upload.jar <path> --recursive

    You will be asked to enter login / password and directories will be traversed recursively.

  3. java -jar google-docs-upload.jar <path> --username <username> --password <password>

    Here the upload will be started immediately, but the files will be taken only from root folder.

You can download the program and the source code here:

I hope it will be useful for somebody :)

Update: I've added the ability to replicate folder structure in Google Docs. Another feature is determination of document duplicates, which you can replace or skip.


Shane said...

Is there anyway that you know of to keep google from converting the files to it's own format? If I upload a bunch of Word Documents I would rather keep them as word documents

Anton said...

Hi Shane,

Recently, this feature has been added to API. Unfortunately, it's only available for Google Premier Accounts. Nevertheless, the support for it will be implemented in the tool in the nearest time.

Unknown said...

Hello, I have created a simple GUI for this utility. Feel free to include it, copy/paste it, use it for TP, whatever...

Anonymous said...

Thanks very much Anton. This works really well and I have found it really helpful.

I second Shane's request - although as my work only have a standard Google Apps account (using our own domain) at this stage it may not work for us anyway!?

Anton said...

Hi Josh,

Thank you for sharing, I will try your code and add it to the project source.

Hi Jedd,

You right, unfortunately at this moment it won't work for accounts that are not Premier.

Dave Fitzhugh said...

Hi Anton,

thanks for your great work, this is a very helpful utility!

Along the lines of the above comments, is it possible just to upload all files in a folder, regardless of file type (supported or unsupported) with no conversion?

I understand about the Premier account, but I'm thinking this would be possible even with a regular account, as google docs now allows upload with no conversion for any file, if you just deselect the convert box.

Anyway, hopefully this could be possible, because it would be a great way to do simple, cloud-based backup of important folders for me.

Thanks again!

Anton said...

Hi Dave,

The problem is that the feature you described is supported by the web interface of Google Docs, but it's not supported by the API. Therefore, I can't implement it for regular accounts. Hopefully, it will become available in the future.


Fran said...

hi there!
I m finding your tool very interesting and I have connected to my account, but I m starting to use google docs as a backup drive and my files have the rar extension. Could you please do something to allow these files to be uploaded?

Best Regards


Cissonius said...

Did google block the clients using the java api , i can't upload anymore ..
I looked at the source, but it seems to handle the conversion flag correctly....


Post a Comment