Exemplary Shell script - Download files
Thu May 06 2021 10:22:22 GMT+0000 (Coordinated Universal Time)
Saved by
@FlorianC
#!/bin/bash
# First parameter is the ID, second parameter is the filename
FILEID=$1
FILENAME=$2
# This script downloads the drive file with the given ID and saves it with the given name
COOKIE_FILE=$(mktemp cookiesXXXX.txt)
# First get the confirmation prompt because the file is too big
CONFIRM=$(wget --quiet --save-cookies ${COOKIE_FILE} --keep-session-cookies "https://docs.google.com/uc?export=download&id=${FILEID}" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')
# Then download the file using the confirmation prompt
wget --load-cookies ${COOKIE_FILE} "https://docs.google.com/uc?export=download&confirm=${CONFIRM}&id=${FILEID}" -O ${FILENAME}
# Finally, delete the cookie file
rm ${COOKIE_FILE}
content_copyCOPY
Comments