Skip to content
TriedPrompts

More in Email, Calendar & Organizing.

Set up a weekly Gmail clean-up script that protects receipts with Gemini

With Gemini, a user built an Apps Script that deleted 5,000+ old emails and now cleans the inbox every Monday.

Result: WorkedTool: GeminiLevel: AdvancedSetup: Needs Apps Script

Copy the prompt

Outcome

Andrew Ledet was tired of repeating a two-hour manual inbox clean-up. Working with Gemini, they built a Google Apps Script 'Janitor' that audits top senders, does a dry run, then clears old promotions, social and update emails while skipping anything from themselves, starred, or that looks like a receipt or order. The first run deleted more than 5,000 emails in a few minutes, and it now runs automatically every Monday at 3 a.m. Ledet began by asking Gemini to measure inbox density: who sends the most and which messages actually get read or answered. Thousands of newsletters made the clutter, but a few old self-sent attachments took the most storage. The script clears promotions, social and update emails after 14 days and the most frequent senders after 7, and skips purchases and subjects with receipt, order or confirmation. Ledet didn't want to pay a monthly fee for a clean-up service and shares the final script in the post.

Evidence: Described by posterThe person describes what happened in words, without screenshots or video.

WorkedEvidence: Described by posterPosted Last checked

Level: Advanced. You need: A tool that takes actions for you or writes code, connected accounts, or some setup on your computer.

How to use this

  1. Tap Copy prompt.
  2. Open Gemini.
  3. Paste it into the message box.
  4. Send it, then read the answer before acting on it.
New to this? What's a prompt?

A prompt is the message you send to the AI tool. Copy the one on this page, put your own details where it asks, and read the answer before you act on it.

Prompt

Recreated prompt

The source didn't share its exact prompt, so we wrote one from what it describes. The result shown is the source's, not ours.

What the prompt labels mean

The person didn't share their exact words, so we wrote this from what they described. We haven't tested it, and they didn't use this exact version.

Before you start, ask me 1–3 short questions about anything important that's missing below. Keep them quick. Then do the task, checking in with me at the key points.

Goal: Help me build a weekly automatic Gmail clean-up that removes old clutter but never touches receipts, starred mail or things I sent.

What I can give you (ask for whatever's missing):
- Which Gmail categories I want cleaned (Promotions, Social, Updates)
- How old emails should be before they go
- Senders I always want cleared and anything I always want kept

Rules:
- Start with a script that only reports my top 20 senders by thread count.
- Then write a dry run that lists what would be deleted and the estimated space saved, and wait for my OK.
- Exclude anything from me, starred, marked important, or that looks like a receipt or order.
- Only then give me the final script and step-by-step instructions for a weekly time-based trigger.
- Check facts that can change (prices, opening hours, dates, availability, rules) against the official source, and tell me anything you couldn't verify.

Output: Three short scripts (audit, dry run, weekly clean-up) with plain-English setup steps.

You'll know it worked when: the clean-up runs on its own each week and nothing I need goes missing.

Try this in:

Sends the Recreated prompt shown above. ChatGPT and Grok open with it filled in, and ChatGPT may send it straight away. Gemini and Claude open empty, so we copy the prompt for you to paste. Every button also copies it.

Opens in a new tab. We don't see what you send.

These links are only a shortcut. We're not affiliated with OpenAI, Google, Anthropic or xAI, and your results may not match the source.

Optional stronger version

Our rewrite with extra checks. The poster didn't test it.

Before you start, ask me 1–3 short questions about anything important that's missing below. Keep them quick. Then do the task, checking in with me at the key points.

Goal: Help me build a weekly automatic Gmail clean-up that removes old clutter but never touches receipts, starred mail or things I sent.

What I can give you (ask for whatever's missing):
- Which Gmail categories I want cleaned (Promotions, Social, Updates)
- How old emails should be before they go
- Senders I always want cleared and anything I always want kept

Rules:
- Start with a script that only reports my top 20 senders by thread count.
- Then write a dry run that lists what would be deleted and the estimated space saved, and wait for my OK.
- Exclude anything from me, starred, marked important, or that looks like a receipt or order.
- Only then give me the final script and step-by-step instructions for a weekly time-based trigger.
- Check facts that can change (prices, opening hours, dates, availability, rules) against the official source, and tell me anything you couldn't verify.
- Explain how to switch the trigger off and where deleted emails go, in case I need to recover one.

Output: Three short scripts (audit, dry run, weekly clean-up) with plain-English setup steps.

You'll know it worked when: the clean-up runs on its own each week and nothing I need goes missing.

Before you finish: re-read my goal and constraints, check your answer against each one, and list anything you assumed or couldn't confirm.

AI tool

Gemini

Source

Posted
by Andrew Ledet (Ask Andrew, Substack)
Last checked
Method:
How we verify

https://askandrew.substack.com/p/taming-the-unruly-inbox

Context: The prompt the writer shares is a version for readers; Gemini's exact replies aren't shown.

Tell us how it went A reader message. It is not published on this page, and it is not a test of the prompt.

More in Email, Calendar & Organizing

More in PersonalRandom case in Personal