Python script to export files from Google Drive
export.py
(export all files in their default formats)
export.py --type spreadsheet
(export all spreadsheets in the default format)
export.py --type spreadsheet --export-formats spreadsheet:csv
(export all spreadsheets in the csv format)
export.py --export-formats spreadsheet:pdf,document:rtf
(export all files with their default export formats except
spreadsheets to be exported to pdf and documents to be
exported to rtf)
export.py --destination-dir /tmp/google-files
(export all files in their default formats but put them in the
directory /tmp/google-files)
This script uses service account credentials to access your Google Docs and download them.
- The script can only download documents that the service account has permission to download.
-
Go to the Google Developer's Console.
-
Log in with your usual Google credentials.
-
Click on the "Credentials" link.
-
Click on the "Create Credentials" pull-down and choose "Service account key".
-
On the "Service account" pull-down choose "New service account".
-
For "Key type" choose JSON.
-
Click the "Create" button.
-
Be sure to save the JSON secret file. This is what you will use to access your files. The script looks for this secret in the file
client_secret.json
. -
To download a Google Drive file your must grant view permission on that file to this e-mail address.