How To Delete all Slack Files to Manage Disk Space

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.

How To Delete all Slack Files to Manage Disk Space

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 channel name in the top right of the screen.
  2. Under the About section, scroll down and select the file you want to delete.
  3. Click on the three-dot menu icon and select Delete file.
  4. 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 on the bottom right of the screen and select Delete.
  3. Select 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!

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