Skip to content

Instantly share code, notes, and snippets.

@Kabongosalomon
Last active July 26, 2021 18:10
Show Gist options
  • Save Kabongosalomon/86333dad37b475d8eb64543ddfce4163 to your computer and use it in GitHub Desktop.
Save Kabongosalomon/86333dad37b475d8eb64543ddfce4163 to your computer and use it in GitHub Desktop.
A script to download content from a google drive link. How to use : bash gdrive.sh <comple-google-driv-link>
#!/bin/bash
gfile=$1
# gfile_ID=(${gfile//// })
gfile_ID=$1
# f1 = ${f1_[0]}
echo "Make sure you extract the file ID from the google link"
echo "e.g. from https://drive.google.com/open?id=1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ extract 1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ"
echo "The code then is run as follow : bash gdrive.sh 1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ"
# echo ${gfile_ID[-2]}
echo ${gfile_ID}
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id='${gfile_ID} -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=${gfile_ID}" -O data && rm -rf /tmp/cookies.txt && unzip data && rm data
@Kabongosalomon
Copy link
Author

Kabongosalomon commented Jul 26, 2021

"Make sure you extract the file ID from the google link"
"e.g. from https://drive.google.com/open?id=1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ extract 1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ"
"The code then is run as follow:

  • bash gdrive.sh 1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ

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