Skip to content

Instantly share code, notes, and snippets.

@amjltc295
Forked from vithalreddy/gd-drive-file-download.sh
Created September 17, 2019 08:20
Show Gist options
  • Save amjltc295/ae8420b96b75920514d773a5a324f199 to your computer and use it in GitHub Desktop.
Save amjltc295/ae8420b96b75920514d773a5a324f199 to your computer and use it in GitHub Desktop.
Shell Script To Download Google Drive Files from terminal
#!/bin/bash
read -p "Enter File Id: " fileid
read -e -p "Enter File Dir: " "path_to_download_dir" dir #replce with your download dir path ~/Downloads
cd ~/$dir
echo "File will be downloaded in dir: ~/{$dir}"
curl -c ./$fileid -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./$fileid "https://drive.google.com/uc?export=download&confirm=`awk \
'/download/ {print $NF}' \
./$fileid`&id=${fileid}" -O -J -L
if [ -f ./$fileid ] ; then
rm -rf ./$fileid
echo "cookie file deleted successfully"
fi
echo "File downloaded in dir: ~/{$dir}"
@amjltc295
Copy link
Author

amjltc295 commented Oct 7, 2019

#!/bin/bash
fileid=$1
echo "FileID: $fileid"

curl -c ./$fileid -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./$fileid "https://drive.google.com/uc?export=download&confirm=`awk \
'/download/ {print $NF}' \
./$fileid`&id=${fileid}" -O -J -L

if [ -f ./$fileid ] ; then
    rm -rf ./$fileid
    echo "cookie file deleted successfully"
fi

echo "File downloaded"

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