0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

slackのファイルを削除するプログラム

Last updated at Posted at 2019-11-11

slackのフリープランは5GBまで

古いファイルを削除したいが、複数選択削除がUIで無いので、プログラムで削除する。

環境

PHP

プログラム

同じこと考えてる人は多い。
丸パクリでおkでした。
https://qiita.com/9umaske/items/49bc1bd89330fe946ff3

slack API を使用するために

slackアプリを作成して、
scopeに「files:read」と「files:write:user」を追加
ワークスペースに追加
tokenを取得しましょう。

使用するAPI

files.list

ts_toを指定することで古いファイルを取得できる。
ただし、ソート順はtimestampで昇順になる(古い→新しい)。

files.delete

files.listで取得したIDを指定して削除する。
slackアプリを作成した人のアカウント権限がadminでないと他の人のファイルを削除できないので、adminになるかadminの人にアプリを作成して貰う必要があります。

動作時間

10個で数秒です。

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?