2
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で3ヶ月以前にアップロードされたファイルを全部消すシェルスクリプト

2
Posted at

Slack を無料で使っているとファイル容量がすぐ満杯になってファイルアップロードができなくなるので cron に登録して毎日掃除していきたいと思います。

SLACK_TOKEN は、ここから発行 https://api.slack.com/custom-integrations/legacy-tokens

SLACK_TOKEN=xoxp-0000000000-0000000000-00000000000-0000000000
curl -sS "https://slack.com/api/files.list?token=${SLACK_TOKEN}&count=1000&ts_to=$(( `date +\%s` - (60 * 60 * 24 * 90) ))&pretty=1" | awk -F'"' '/"id":/{print $4}' | while read FILE_ID; do echo -n "${FILE_ID} "; curl -sS "https://slack.com/api/files.delete?token=${SLACK_TOKEN}&file=${FILE_ID}"; echo; sleep 1; done
2
1
0

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
2
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?