Transferring large files from google drive on command line using gdrive
Downloading large google drive files via gdrive on Mac and Linux seems to be faster than using the wifi connection directly or with something like curl.
Installation
On OSX, you can install via homebrew using:
On linux, you’ll have to download the custom installation file from github. There seems to be a version for windows but I haven’t tried that.
Establish a connection to your google drive
- to establish the initial connection, when you first run gdrive an access token is granted through a browser link with a prompt of something like ‘Authentication needed; Go to the following url in your browser:’
- it seems you may have to reauthenticate the connection every so often because the token will expire. Borrowing from the solution by Stunner in this Github issue, the following works for me to re-establish the connection:
Download a file or directory
- you can get a google drive id for each file or directory by right-clicking the file name and selecting ‘get shareable link’. The characters after ‘id =’ is the File ID. It seems the file id will not change if you change permissions or turn off link sharing.
- For example, the link and corresponding id might be something like:
- You can do a simple download with the command ‘gdrive download
' but there are also additional options listed on the github page. For example, add the flag '-r' (recursive) to download a directory recursivey.
Example gdrive first setup
- This is what the outputs looked like for me during setup of gdrive with some fake urls:
https://drive.google.com/open?id=11d0WKhSK9oWvx4NiGu7zsCzvxwQjotZ5
Written on July 3, 2019