This script allows you to delete your old Reddit posts and comments automatically. It uses the PRAW (Python Reddit API Wrapper) library to access the Reddit API and delete posts and comments based on a given time threshold.
- Clone the repository:
git clone https://github.com/JosemyDuarte/reddit-cleaner.git
- Install the required packages:
pip install -r requirements.txt
- Go to https://www.reddit.com/prefs/apps and create a new "script" type application. You can name it whatever you like and set the description and about url to anything you want.
- Set the following environment variables with your Reddit account information:
REDDIT_CLIENT_ID=<your_client_id>
REDDIT_CLIENT_SECRET=<your_client_secret>
REDDIT_USERNAME=<your_reddit_username>
REDDIT_PASSWORD=<your_reddit_password>
REDDIT_USER_AGENT=<your_user_agent>
You got the client_id
and client_secret
on previous step by creating the app. For the user_agent, you can use any
string that identifies your script.
- (Optional) Set the
REDDIT_DELETE_THRESHOLD
environment variable to specify the number of days before which posts and comments will be deleted. By default, anything older than a year will be deleted.
REDDIT_DELETE_THRESHOLD=365
- Run the script:
python delete_posts_and_comments.py
This script was inspired by Adrian Tombu's Twitter cleaning script. Although for me, it was enough running it locally, so there is no Github Actions cron.