LinuxCommandLibrary

gdown

Download files from Google Drive

TLDR

Download a file from a URL

$ gdown [url]
copy

Download using a file ID
$ gdown [file_id]
copy

Download with fuzzy file ID extraction (also works with links)
$ gdown --fuzzy [url]
copy

Download a folder using its ID or the full URL
$ gdown [folder_id|url] [[-O|--output]] [path/to/output_directory] --folder
copy

Download a tar archive, write it to stdout and extract it
$ gdown [tar_url] [[-O|--output]] - [[-q|--quiet]] | tar xvf -
copy

SYNOPSIS

gdown [OPTIONS] URL | --id FILE_ID | --folder FOLDER_URL

PARAMETERS

-O, --output
    Specifies the output file path or directory. gdown will save the downloaded file to this location.

--id
    Downloads a file by its Google Drive ID. Useful when you only have the ID and not a full URL.

--folder
    Downloads an entire Google Drive folder. Requires the --recursive option for nested content.

-q, --quiet
    Suppresses output. Only errors will be displayed, making it suitable for scripting.

--no-check-certificate
    Disables SSL certificate verification. Use with caution, primarily for self-signed certificates in controlled environments.

--fuzzy
    Enables fuzzy matching for file names. Useful when the exact filename isn't known for a folder download.

--recursive
    Downloads contents of a folder recursively. Required when using --folder to get all sub-files and folders.

--convert
    Converts Google Docs, Sheets, or Slides to standard formats. E.g., a Google Doc will be converted to PDF.

--unzip
    Unzips a downloaded zip file automatically. Saves the contents to the output directory.

--remaining-attempts
    Sets the maximum number of download attempts. Useful for unreliable networks or temporary Google Drive issues.

-h, --help
    Displays help message and exits.

-V, --version
    Shows the program's version and exits.

DESCRIPTION

gdown is a command-line utility designed to simplify downloading files and folders from Google Drive. It acts as a convenient wrapper around the Google Drive API, specifically handling common scenarios that make direct downloads via tools like wget or curl difficult, such as Google's "too many downloads" warning pages or the need to bypass browser-based prompts.

It's particularly useful for downloading large public files, datasets, or shared content directly from the terminal without requiring manual interaction with a web browser. Beyond simple file downloads, gdown can also download entire shared Google Drive folders recursively and supports conversion of Google-specific document formats (like Docs, Sheets, Slides) into standard formats such as PDF, XLSX, or PPTX. It's built on Python and typically installed via pip, making it cross-platform and easy to integrate into scripts.

CAVEATS

gdown primarily relies on public or shared Google Drive links. Downloading private files requires additional authentication steps, which are beyond the typical command-line usage and often involve configuring Google API credentials.

While it handles Google's download limits better than direct methods, extreme usage might still trigger temporary blocks. For very large folder structures or extremely slow networks, gdown's performance might not match dedicated sync tools like rclone, which are optimized for persistent connections and resumable transfers.

INSTALLATION

gdown is a Python package and can be easily installed using pip, the Python package installer.

To install: pip install gdown

Ensure you have Python and pip installed on your system.

USAGE EXAMPLES

Basic File Download:
gdown https://drive.google.com/uc?id=YOUR_FILE_ID

Download to Specific File:
gdown --output my_downloaded_file.zip https://drive.google.com/uc?id=YOUR_FILE_ID

Download a Folder Recursively:
gdown --folder --recursive https://drive.google.com/drive/folders/YOUR_FOLDER_ID

Download by File ID:
gdown --id YOUR_FILE_ID

HISTORY

The gdown utility originated as a convenient Python package to address the common challenges of downloading files from Google Drive, particularly large files that trigger browser warnings or require bypassing manual prompts. It was developed by W. Kato (wkentaro) and quickly gained popularity within the machine learning and data science communities for easily downloading pre-trained models and datasets often hosted on Google Drive. Its development has focused on providing a simple, robust command-line interface for Google Drive downloads, abstracting away the complexities of Google's API and web interface interactions.

SEE ALSO

wget(1), curl(1), rclone(1)

Copied to clipboard