Skip to content

A Google Apps Script that helps you delete Gmail messages older than n days that match your custom regex filters.

License

Notifications You must be signed in to change notification settings

chriskyfung/gmail-regex-cleaner-apps-script

Repository files navigation

Gmail Regex Cleaner

Build Status code style: prettier License: AGPL v3 GitHub issues GitHub stars

A Google Apps Script that helps you delete old emails in Gmail that match your custom regex filters. This can help you save space and keep your inbox organized.

Table of Contents

About The Project

This project provides a flexible way to automatically clean up your Gmail inbox by deleting old emails that match specific criteria defined by regular expressions. It's perfect for managing recurring emails like newsletters, notifications, and alerts that you don't need to keep forever.

Features

  • Delete old emails in Gmail that match a regular expression
  • Specify the number of days to keep the emails
  • Exclude starred, important, or labeled emails from deletion
  • Run the script manually or on a schedule
  • Log the deleted emails and errors

Getting Started

Warning

This script will delete your emails permanently, without moving them to the trash. Please use it with caution and make sure you have a backup of your important emails. You can run the script with the isDryRun option set to true first to see what emails will be deleted.

This section will guide you through the process of setting up and running the script.

Prerequisites

  • A Google account with access to Gmail and Google Drive.

Installation

  1. Create a new Google Apps Script project in Google Drive.

  2. Copy and paste the code from dist/code.js and dist/examples.js into the script editor.

  3. From the examples.js file, choose a function that matches your needs, or create a new one. You can then run this function from the Apps Script editor.

    For example, to run one of the pre-made functions, you would select it in the editor's function list and click Run.

Important

When running the script for the first time, you may need to authorize it to access your Gmail account.

  1. Optionally, set up a trigger to run a function periodically. You can do this by clicking the Triggers icon in the left sidebar, then clicking the Add a trigger button, and choosing the options you want. For example, you can set the script to run every day, week, or month.

Usage

For detailed instructions on how to set up and use this script, please see the Usage Guide.

Development

This project uses ESLint for linting, Prettier for formatting, Jest for testing, and Rollup for building. For more details on the development setup and build process, please see the Development Guide.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please read the CODE_OF_CONDUCT.md before contributing.

If you have a bug report or a feature request, please open an issue on the GitHub Issues page.

License

This project is distributed under the AGPL-3.0 license. You can use, modify, and distribute this project, as long as you comply with the terms and conditions in the LICENSE file.

Disclaimer

This script is provided as is, without any warranty or liability. Use it at your own risk. Make sure to test the script before using it on your Gmail account. The script may delete emails that you want to keep, or fail to delete emails that you want to remove. The script may also exceed the quota limits of Google Apps Script or Gmail API, resulting in errors or partial execution. The author is not responsible for any loss or damage caused by the use of this script.

About

A Google Apps Script that helps you delete Gmail messages older than n days that match your custom regex filters.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 3

  •  
  •  
  •