Delete All Saved Reddit Posts and Comments

Delete All Saved Reddit Posts and Comments

tl;dr requires python, pip, and praw get the source here: https://gist.github.com/robmusial/e68f87488a30fd98dff3882c03577dc6

Similar to web page bookmarks I have a bad habit of saving every Reddit post I like. I went to looking for a script that could automatically delete them all and found one from Patrick Lewery Harris.

It worked great, but needed some tweaks to:

  1. Work with my username
  2. Not risk having my password in my shell history

The original script uses argparse and doesn’t like usernames that start with a “-”, which mine does. So rather than try to fix that I just ripped out argparse bits and now you just set the variables inside the script itself.

So fire up your editor of choice and edit:

username = ""
password = ""
client_id = ""
client_secret = ""

Username and password are… your Reddit username and password. The client_id and client_secret you get by creating an app in Reddit. Go to reddit.com, login, and (at least using old.reddit.com) go to preferences –> apps –> create app. Click “script”, name it whatever you want and give it any description you want. For both about and redirect I usually use https://localhost.localdomain. Click create app and now you’ll see the client_id under the script name and you’ll see the client_secret labeled “secret”.

To run the script run % python delete_all.py

You’ll see your client_id, client_secret, and username echo as it deletes your saved posts and comments. You might have to run it a few times depending on how much you have saved, or you can run something like % watch -n 10 python delete_all.py

Have fun feeling unburdened by posts you’ll never revisit or read again!

Rob Musial

A kernel abstracting a kernel disguised as another kernel.


2022-05-24