Shell Script To Download Google Drive Files from terminal

  Google Drive, Shell script

How to use:

wget https://mkbentre.com/share/ggdownload.sh & chmod +x ggdownload.sh
./ggdownload.sh <id_file>

Code:

#!/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"
FILE_ID="FILE ID"
OUTPUT="OUTPUT FILE NAME"
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=${FILE_ID}" > /dev/null
CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=${FILE_ID}" -o ${OUTPUT}

6.057 thoughts on - Shell Script To Download Google Drive Files from terminal

LEAVE A COMMENT