๐ Good day, dear community!
Even though the AI GPT race is in full swing, bringing us many competitive alternatives on the marketโsuch as DeepSeek, Llama, Claude, and others โ Iย remain an active ChatGPT user.
If you're like me and use it daily for work, seeking inspiration, or even finding answers to clumsy or silly questions, I invite you to read this article. It might just make your experience with ChatGPT a little shinier!
Introduction
If you're an active ChatGPT user, chances are your chat history is cluttered with dozens or even hundreds of conversations. While ChatGPT is an amazing tool, its UI lacks a simple way to remove multiple chats at once. This means you have to manually delete each chat, wasting time on repetitive actions.
To solve this, I created chatGptCleaner.sh
, a simple shell script that automates chat removal using ChatGPT's API calls. With this script, you can:
- Delete multiple chats at once
- Filter chats by name using regex
- Avoid accidental deletion with confirmation prompts
How It Works
To use the script, you will need to obtain your Authentication Token from your browser and place it in the script. The script mimics the way ChatGPT removes chats through its UI but with the added ability to delete multiple conversations simultaneously. It uses:
-
curl
for making HTTP requests -
jq
for parsing and filtering JSON responses
Installation
First, ensure you have curl
and jq
installed. Use the appropriate command for your OS:
OS | Installation Command |
---|---|
macOS (Homebrew) | brew install curl jq |
Ubuntu/Debian | sudo apt update && sudo apt install -y curl jq |
CentOS/RHEL | sudo yum install -y curl jq |
Fedora | sudo dnf install -y curl jq |
openSUSE | sudo zypper install -y curl jq |
Usage
1) Get Your Authentication Token:
- Open ChatGPT and log in.
- Open Developer Tools (F12 or Ctrl + Shift + I in most browsers) and go to the
Network
tab. - Click on a conversation to trigger an API request.
- Look for a request containing an
Authorization
header and copy its value. - Paste the token into the
AUTHORIZATION
variable at line 7 of the script. If the token includesBearer
, remove it.
2) Run the Script:
./chatGptCleaner.sh --number=10
The script will fetch your most recent chats and display a list of chats that will be deleted. You will need to confirm before proceeding by pressing y
or decline with n
.
3) Filter Chats Using Regex. You can exclude important chats using a regex pattern, read more about supported patterns here. For example, to delete all chats except those containing #
:
./chatGptCleaner.sh --number=10 --filter='^(?!.*#).*'
Why Use This Script?
- โณ Saves Time: No more manual deletion, one chat at a time.
- โ Safe to Use: Requires user confirmation before deleting.
- ๐ Flexible: Supports regex-based filtering.
- โก Lightweight: No need for heavy dependencies.
Conclusion
If you've been frustrated by ChatGPTโs lack of bulk chat deletion, this script is a simple and effective solution. Feel free to try it out, modify it, and contribute! The script is open-source and available on GitHub.
๐ GitHub Repository
If you found this helpful, let me know in the comments, and feel free to share your improvements!
Happy coding! ๐
Top comments (0)