Skip to content

Instantly share code, notes, and snippets.

@ntdat017
Created January 11, 2022 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntdat017/e6564707c8e77b2ebeb4a0c3d6d5af1d to your computer and use it in GitHub Desktop.
Save ntdat017/e6564707c8e77b2ebeb4a0c3d6d5af1d to your computer and use it in GitHub Desktop.
script to google drive downloading
#!/usr/bin/env bash
drive_download() {
if [[ -f "$3/$2" ]]; then
echo "$2 already existed"
return
fi
echo "$2 not found, downloading..."
mkdir -p "$3"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=$1" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=$1" -o "$3/$2"
rm -rf ./cookie
echo "$2 is downloaded succesfully"
}
drive_download "11YIF6MssAfT0-Lah11SgpsOThyBkmyhd" "sample_text.txt" "./"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment