Skip to content

Instantly share code, notes, and snippets.

@zx0r
Created January 30, 2025 18:42
Show Gist options
  • Save zx0r/0ec2ef36d9e5964b06b25ba9a8faa979 to your computer and use it in GitHub Desktop.
Save zx0r/0ec2ef36d9e5964b06b25ba9a8faa979 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Script Name: download_gist_files.sh
# Description: Automates the process of downloading all files from a GitHub Gist.
# Uses the GitHub Gist API to fetch file metadata and downloads each file.
# Author: zx0r
# Date: 2025.01.30
# Version: 1.0
# Usage: ./download_gist_files.sh <GIST_ID>
# Example: ./download_gist_files.sh 843298b67cd91a0835dcf36aada529d5
# Dependencies: curl, jq
# License: MIT
GIST_ID="843298b67cd91a0835dcf36aada529d5" # Replace
GIST_URL="https://api.github.com/gists/$GIST_ID"
# Fetch the Gist metadata
GIST_DATA=$(curl -s "$GIST_URL")
# Parse and download each file
echo "$GIST_DATA" | jq -r '.files | to_entries[] | .value.raw_url' | while read -r FILE_URL; do
FILE_NAME=$(basename "$FILE_URL")
echo "Downloading $FILE_NAME..."
curl -s -o "$FILE_NAME" "$FILE_URL"
done
echo "All files downloaded!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment