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
- Email with attachment arrives (or matches a label)
- File downloaded by the script
- AI names it from content and routes to a folder
- 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
- Create a Gmail label named 'Auto-File' in Settings → Labels.
- Create filters that apply Auto-File to the senders or topics you want captured (invoices from X, contracts from Y).
- In Google Cloud enable Gmail API and Drive API; create OAuth credentials.
- 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
- In Google Drive create top-level folders: Invoices, Contracts, Receipts, Other.
- Create the same structure inside a single Drive parent folder (e.g. 'Auto-Filed').
- Optionally add subfolders matching sender names for very frequent senders.
- 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
- Build the prompt: 'Rename this file contextually. Return JSON: {fileName, folder}. Prefer Vendor + Date + Type (e.g. Acme_2026-10-01_Invoice.pdf).'
- Tell it which folder names are allowed — it must pick from the exact folder list.
- Paste prompt and API key into the script's HTTP call.
- 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
- Create a sheet 'File Index' with columns: Original Name, Saved As, Folder, Date, Email Subject.
- After moving each file, append the row.
- Test: email yourself a PDF, wait a trigger cycle, and confirm the file appears in Drive with its new name and a sheet row.
- 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.