4

How To Delete all Slack Files to Manage Disk Space

Posted by Jamie on August 15, 2018

Slack is the tool of choice for many enterprises and companies that collaborate over distance. It’s a productivity powerhouse that encompasses chat, file sharing, project management tools and a huge range of addons that offer a lot of power to the app. What usually happens within a Slack group is a lot of files are shared with little version control and a lot of mess to clean up once the project is complete. If you’re cleaning up after such a project, here is how to delete all Slack files without deleting the workspace.

Slack keeps everything. As long as the workspace is kept alive, all of the files, channels, chats and everything you shared will be kept. You could archive or delete a workspace but given that it takes a little time to set up and break down, if you’re planning to bring the team together again for another project, it might not be worth it. Far better to perform a little housekeeping to keep things tidy.

The main limitation with Slack is disk space. With everything being saved, you will quickly run through 5GB of space in even a modest project. To help manage space, you can delete files that take up too much of it. That’s what this tutorial is all about.

Members and Guests can be configured to delete files or the workspace administrator can withhold permission. Either way, you can delete individual Slack files without any addons but to delete all Slack files within a workspace, you’ll need a script.

Delete Slack files

Exactly how you delete Slack files depends entirely on what platform you’re using. It differs slightly between desktop, Android and iOS so I’ll show you all of them. You can delete a file you personally added to a workspace or from a shared channel. Anyone can delete files they add but only Workspace Owners or Administrators can delete files from shared channels. The method is the same for both.

On desktop:

  1. Select the three dot menu icon in the top right of the screen.
  2. Select Your Files and select the file you want to delete.
  3. Select Delete and then confirm with Yes, delete this file.

On Android:

  1. Select the file you want to delete from within Slack.
  2. Select the three dot menu icon in the top right of the screen.
  3. Select Delete and then Delete again to confirm.

In iOS:

  1. Select Your Files within Slack.
  2. Select a file to delete.
  3. Select the three dot menu icon in the bottom right of the screen.
  4. Select Delete and then Yes, Delete File to confirm.

You can only select to delete one file at a time whichever platform you use. If you only have a couple files, this should be fine. If you have more, you will need to use an addon or script.

Delete all Slack files in bulk

To delete all Slack files in bulk you will need to use a script. There are a few good ones on GitHub that are free to use. They do require Python to be installed into your computer to be able to run them but that is easily taken care of. The script I include below will delete all files older than 30 days. This helps save disk space while keeping the latest versions of files available for the team.

  1. Download and install Python from here.
  2. Install the Requests library in Python from here.
  3. Get yourself an API key from Slack.
  4. Create a file with Notepad or text editor and call it something meaningful. It must have the suffix .py to work in Python.
  5. Paste the script below into your .py file.
  6. Add your Slack API key where it says token = ”. EG: token = ‘API KEY HERE’.
  7. Save the script and then run it.

The script text you need to paste:

import requests

import time

import json

token = ''

#Delete files older than this:

ts_to = int(time.time()) - 30 * 24 * 60 * 60


def list_files():

  params = {

    'token': token

    ,'ts_to': ts_to

    ,'count': 1000

  }

  uri = 'https://slack.com/api/files.list'

  response = requests.get(uri, params=params)

  return json.loads(response.text)['files']


def delete_files(file_ids):

  count = 0

  num_files = len(file_ids)

  for file_id in file_ids:

    count = count + 1

    params = {

      'token': token

      ,'file': file_id

      }

    uri = 'https://slack.com/api/files.delete'

    response = requests.get(uri, params=params)

    print count, "of", num_files, "-", file_id, json.loads(response.text)['ok']

files = list_files()

file_ids = [f['id'] for f in files]

delete_files(file_ids)

This script is not my work but was taken from GitHub. All credit must go to the author for the code.

Managing disk space is one of the main challenges of using Slack and deleting old files is a good way of overcoming that limitation. If you’re managing a team or workspace, now you know how to delete all Slack files to manage disk space!

4 thoughts on “How To Delete all Slack Files to Manage Disk Space”

Hasmik says:
I am not Workspace Owner or Administrator, just a member.

When received notification from Slack
”doesn’t have any storage space left. To get more space, you can upgrade to a paid account or delete some of your older files.”
deleted 20-30 files from ”Your files” but still receiving same notification about full storage.

What can I do? Maybe administrators need to delete files?

Thanks in advance,
Hasmik

Reply
paolo says:
I am getting permission denied when trying to delete files in bulk through my terminal using the ,py script. I am not as tech savvy, any ideas on why?
Reply
dub73 says:
how can I delte all files at once?
Reply

Leave a Reply

Your email address will not be published. Required fields are marked *


Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.