Skip to content

Email & Inbox

Attachment Organizer

Attachments from email get saved to Drive with smart names — searchable forever.

Saves about ~1 hr per week

What it does

  • Watches for emails with attachments
  • Extracts files and renames them from their content
  • Files them into the right Drive folder
  • Logs a searchable index to a sheet

How it works

  1. Email with attachment arrives (or matches a label)
  2. File downloaded by the script
  3. AI names it from content and routes to a folder
  4. Index row written to the sheet

What's included

  • Label + filter setup
  • Drive folder routing
  • Naming prompt

Set it up yourself

Follow these 4 steps in order. You will need accounts for: Gmail, Drive.

Step 1: Set the watch scope

  1. Create a Gmail label named 'Auto-File' in Settings → Labels.
  2. Create filters that apply Auto-File to the senders or topics you want captured (invoices from X, contracts from Y).
  3. In Google Cloud enable Gmail API and Drive API; create OAuth credentials.
  4. Note: the script reads the Auto-File label, so mail must match a filter first.

Watch out: Do not apply the label to everything — only to content you actually want filed, or you will archive junk.

Step 2: Create the folder structure

  1. In Google Drive create top-level folders: Invoices, Contracts, Receipts, Other.
  2. Create the same structure inside a single Drive parent folder (e.g. 'Auto-Filed').
  3. Optionally add subfolders matching sender names for very frequent senders.
  4. Note each folder's name exactly — routing rules use folder names.

Watch out: Use separate top-level folders, not Drive colour tags — scripts route by path.

Step 3: Add the naming prompt

  1. Build the prompt: 'Rename this file contextually. Return JSON: {fileName, folder}. Prefer Vendor + Date + Type (e.g. Acme_2026-10-01_Invoice.pdf).'
  2. Tell it which folder names are allowed — it must pick from the exact folder list.
  3. Paste prompt and API key into the script's HTTP call.
  4. Test on 3 sample files and inspect the names + folder picks.

Watch out: If folder names are free-form, the model invents folders — the allow-list instruction prevents that.

Step 4: Log to the index sheet

  1. Create a sheet 'File Index' with columns: Original Name, Saved As, Folder, Date, Email Subject.
  2. After moving each file, append the row.
  3. Test: email yourself a PDF, wait a trigger cycle, and confirm the file appears in Drive with its new name and a sheet row.
  4. Set time-based trigger every 10-15 minutes with error notifications.

Watch out: The index sheet is your audit trail — if a file vanishes, the row tells you where it went.

Frequently asked questions

What does the Attachment Organizer automation do?

Attachments from email get saved to Drive with smart names — searchable forever. Watches for emails with attachments

How much time does Attachment Organizer save?

It is estimated to save ~1 hr per week. Actual savings depend on your volume.

Which tools does Attachment Organizer use?

It works with Gmail and Drive.

What does Attachment Organizer include?

Label + filter setup, Drive folder routing, Naming prompt.

Can I set up Attachment Organizer myself?

Yes. The do-it-yourself guide on this page walks through 4 steps, from getting access to testing the finished automation.