Skip to content

Instantly share code, notes, and snippets.

@Maxr1998
Forked from greird/slack-files-downloader.sh
Last active September 5, 2024 20:42
Show Gist options
  • Save Maxr1998/4e60045dd734068af0a063751a70aefa to your computer and use it in GitHub Desktop.
Save Maxr1998/4e60045dd734068af0a063751a70aefa to your computer and use it in GitHub Desktop.
Create aria2 input file from all files from a Slack workspace export folder.
#!/bin/bash
#
# This script will browse a Slack export folder and generate an aria2 input file to download all files to an "attachments" folder in each channel folder.
#
# HOW TO:
# 1. As a Workspace admin, download an export of your Slack history (https://www.slack.com/services/export)
# 2. Make sure you have jq installed (https://stedolan.github.io/jq/)
# 3. Place this file at the root of your Slack export folder, next to channels.json
# 4. Run `bash slack-downloader.sh` in your terminal
#
output_file=file_download_list
: > "$output_file"
for channel in $(cat channels.json | jq -rc '.[].name'); do
printf "\n============================================\nLooking into #$channel...\n============================================\n"
jq -r -c '.[].files | select(length > 0) | .[] | select(.is_external == false) |
.url_private_download + "\n" +
" dir='$channel'/attachments\n" +
" out=" + .id + "-" + .name' $channel/*.json >> "$output_file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment