Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adefelicibus/ac099afe3fbcad42252e59177a9a0334 to your computer and use it in GitHub Desktop.
Save adefelicibus/ac099afe3fbcad42252e59177a9a0334 to your computer and use it in GitHub Desktop.
Download Google Drive files with WGET
Download Google Drive files with WGET
Example Google Drive download link:
https://docs.google.com/open?id=[ID]
To download the file with WGET you need to use this link:
https://googledrive.com/host/[ID]
Example WGET command:
wget -O file https://googledrive.com/host/[ID]
@adefelicibus
Copy link
Author

Setup:

Add this code to your ~/.bash_aliases file.

function gdrive_download () {
  CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$1" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')
  wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$CONFIRM&id=$1" -O $2
  rm -rf /tmp/cookies.txt
}

Open new bash session.
Usage:

gdrive_download long_google_drive_file_id filename.ext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment