Skip to content

Instantly share code, notes, and snippets.

@vadimkantorov
Last active October 27, 2021 10:21
Show Gist options
  • Save vadimkantorov/84d9bda8bc7c3869ed679fc6b2646cab to your computer and use it in GitHub Desktop.
Save vadimkantorov/84d9bda8bc7c3869ed679fc6b2646cab to your computer and use it in GitHub Desktop.
Bash script for downloading a file from Google Drive by its ID using wget
# Method from https://gist.github.com/vladalive/535cc2aff8a9527f1d9443b036320672
# Usage (download UP-DETR checkpoint published at https://github.com/dddzg/up-detr, https://drive.google.com/file/d/1_YNtzKKaQbgFfd6m2ZUCO6LWpKqd7o7X/view?usp=sharing)
# downloadgdrive 1_YNtzKKaQbgFfd6m2ZUCO6LWpKqd7o7X # -> ./1_YNtzKKaQbgFfd6m2ZUCO6LWpKqd7o7X
# downloadgdrive 1_YNtzKKaQbgFfd6m2ZUCO6LWpKqd7o7X abc # -> ./abc
function downloadgdrive() { wget --load-cookies googlecookies.txt "https://docs.google.com/uc?export=download&confirm="$(wget --quiet --save-cookies googlecookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$1" -O- | sed -rn "s/.*confirm=([0-9A-Za-z_]+).*/\1\n/p")"&id=$1" -O ${2:-$1}; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment