Skip to content

Instantly share code, notes, and snippets.

@matthewmayer
Created December 30, 2015 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewmayer/ce5cac155260cbb17aa8 to your computer and use it in GitHub Desktop.
Save matthewmayer/ce5cac155260cbb17aa8 to your computer and use it in GitHub Desktop.
import requests
import json
import calendar
from datetime import datetime, timedelta
#lists all files above 10MB in your slack files repo
#based on https://www.shiftedup.com/2014/11/13/how-to-bulk-remove-files-from-slack
_token = ""
_domain = ""
if __name__ == '__main__':
page = 1
MB = 1000000
while 1:
files_list_url = 'https://slack.com/api/files.list'
data = {"token": _token, "page": page}
response = requests.post(files_list_url, data = data)
if len(response.json()["files"]) == 0:
break
for f in response.json()["files"]:
if f['size']>10*MB:
print "%s (%s MB)" % (f['permalink'], f['size']/MB)
page = page+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment