<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Maksym Karatai</title>
    <description>The latest articles on DEV Community by Maksym Karatai (@karmak).</description>
    <link>https://dev.to/karmak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2838784%2F4d1a7ee8-beb9-44f3-aa1a-e87fbd6113e5.jpg</url>
      <title>DEV Community: Maksym Karatai</title>
      <link>https://dev.to/karmak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karmak"/>
    <language>en</language>
    <item>
      <title>Deleting multiple ChatGPT chats with a bash script</title>
      <dc:creator>Maksym Karatai</dc:creator>
      <pubDate>Wed, 12 Feb 2025 20:02:40 +0000</pubDate>
      <link>https://dev.to/karmak/deleting-multiple-chatgpt-chats-with-a-bash-script-11de</link>
      <guid>https://dev.to/karmak/deleting-multiple-chatgpt-chats-with-a-bash-script-11de</guid>
      <description>&lt;p&gt;👋 Good day, dear community! &lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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!&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;To solve this, I created &lt;a href="https://github.com/MaksymKaratai/tools/blob/f269160599a9f761728533e0f9594b375916cae8/chatGptCleaner/chatGptCleaner.sh" rel="noopener noreferrer"&gt;&lt;code&gt;chatGptCleaner.sh&lt;/code&gt;&lt;/a&gt;, a simple shell script that automates chat removal using ChatGPT's  API calls. With this script, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Delete multiple chats at once&lt;/li&gt;
&lt;li&gt;Filter chats by name using regex&lt;/li&gt;
&lt;li&gt;Avoid accidental deletion with confirmation prompts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;curl&lt;/code&gt; for making HTTP requests&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jq&lt;/code&gt; for parsing and filtering JSON responses&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;First, ensure you have &lt;code&gt;curl&lt;/code&gt; and &lt;code&gt;jq&lt;/code&gt; installed. Use the appropriate command for your OS:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;OS&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Installation Command&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;macOS (Homebrew)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew install curl jq&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ubuntu/Debian&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt install -y curl jq&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CentOS/RHEL&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo yum install -y curl jq&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fedora&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo dnf install -y curl jq&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;openSUSE&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo zypper install -y curl jq&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1) Get Your Authentication Token:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open &lt;a href="https://chatgpt.com/" rel="noopener noreferrer"&gt;ChatGPT&lt;/a&gt; and log in.&lt;/li&gt;
&lt;li&gt;Open Developer Tools (F12 or Ctrl + Shift + I in most browsers) and go to the &lt;code&gt;Network&lt;/code&gt; tab.&lt;/li&gt;
&lt;li&gt;Click on a conversation to trigger an API request.&lt;/li&gt;
&lt;li&gt;Look for a request containing an &lt;code&gt;Authorization&lt;/code&gt; header and copy its value.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv5fv7h12shgl7ou0oab0.png" alt="Request" width="800" height="342"&gt;
&lt;/li&gt;
&lt;li&gt;Paste the token into the &lt;code&gt;AUTHORIZATION&lt;/code&gt; variable at &lt;strong&gt;line 7&lt;/strong&gt; of the script. If the token includes &lt;code&gt;Bearer&lt;/code&gt;, remove it.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3zjcmdlmfz2ar8rm8261.png" alt="Authorization token" width="800" height="434"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2) Run the Script:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./chatGptCleaner.sh --number=10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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 &lt;code&gt;y&lt;/code&gt; or decline with &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ahb4od2jyvrfskc8ls4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ahb4od2jyvrfskc8ls4.png" alt="Execution_1" width="800" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3) Filter Chats Using Regex.&lt;/strong&gt; You can exclude important chats using a regex pattern, read more about supported patterns &lt;a href="https://jqlang.org/manual/#regular-expressions" rel="noopener noreferrer"&gt;here&lt;/a&gt;. For example, to delete all chats &lt;strong&gt;except&lt;/strong&gt; those containing &lt;code&gt;#&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./chatGptCleaner.sh --number=10 --filter='^(?!.*#).*'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fev7ma7f4odakjdcrv9pb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fev7ma7f4odakjdcrv9pb.png" alt="Execution_2" width="800" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use This Script?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;⏳ &lt;strong&gt;Saves Time:&lt;/strong&gt; No more manual deletion, one chat at a time.&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Safe to Use:&lt;/strong&gt; Requires user confirmation before deleting.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Flexible:&lt;/strong&gt; Supports regex-based filtering.&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;Lightweight:&lt;/strong&gt; No need for heavy dependencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/MaksymKaratai/tools/tree/f269160599a9f761728533e0f9594b375916cae8/chatGptCleaner" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you found this helpful, let me know in the comments, and feel free to share your improvements!&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>bash</category>
      <category>automation</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
