Skip to content

Instantly share code, notes, and snippets.

@ankitmundada
Last active April 17, 2022 23:11
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save ankitmundada/7d15bc85ff1430d99a8467767c8ed2d2 to your computer and use it in GitHub Desktop.
Save ankitmundada/7d15bc85ff1430d99a8467767c8ed2d2 to your computer and use it in GitHub Desktop.
Shell Script to download Publicly shared Google drive files
#!/bin/bash
# Get files from Google Drive
# Source: https://stackoverflow.com/a/50573452/2382312
# Usage: download_gdrive FILE_ID DESTINATION_PATH
# $1 = file ID
# $2 = file name
URL="https://drive.google.com/uc?export=download&id=$1"
wget --load-cookies /tmp/cookies.txt "https://drive.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate $URL -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=$1" -O $2 && rm -rf /tmp/cookies.txt
@vinaysyadav
Copy link

vinaysyadav commented May 2, 2020

This worked in my case.

wget --no-check-certificate "https://drive.google.com/uc?export=download&confirm=abcd&id=$1" -O $2

@froschgrosch
Copy link

This worked nicely for me as well, thank you!

@xpseudonym
Copy link

Cracking little bit of code, thanks.

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