Automatic Email Attachment Organizer to Google Drive - n8n Workflow

Automate saving Gmail attachments to organized Google Drive folders. Use this robust n8n workflow to handle email subjects and creation dates for structured storage using the n8n node architecture.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Freelancers and professionals managing client documents or incoming invoices.

  • Executive assistants needing to archive specific email attachments efficiently.

  • Users seeking an automated, structured file management system between Gmail and Google Drive.

  • Anyone utilizing the n8n platform to build complex file synchronization processes.

Overview

Managing high volumes of incoming email attachments can be a significant drag on productivity. This expert n8n workflow provides a robust solution for automating this tedious organization task. Instead of manually downloading files from Gmail and sorting them into Google Drive, this powerful n8n template automatically detects new emails using the specialized Gmail n8n trigger node.

The core value of this n8n workflow lies in its dynamic folder creation. It uses the email subject line and the current timestamp to generate a unique, contextually relevant folder name within Google Drive, ensuring chronological and structured organization. This specific n8n workflow enhances efficiency, seamlessly integrating cloud storage and email platforms while demonstrating the flexibility of the standard n8n node architecture.

How it Works

This n8n workflow operates in a sequential, structured manner:


  1. Trigger Activation: The process begins with the Gmail Trigger n8n node, which constantly polls for new emails. Crucially, it is configured to automatically download any attachments detected.

  2. Attachment Check: The Filter n8n node checks if the incoming item contains binary data (an attachment). If no attachment is found, the workflow stops for that email.

  3. Detailed Retrieval: The Gmail n8n node then retrieves the full message details again, ensuring all attachment metadata and binary content is properly loaded for subsequent steps.

  4. Folder Creation: Parallel to the data retrieval, the Create Folder Google Drive n8n node executes. It creates a new folder in the root of Google Drive, using an expressive name like Motion - [Email Subject] - [Timestamp].

  5. Attachment Preparation: The Split Out n8n node processes the binary data (the attachments). If an email had multiple attachments, this node ensures each file becomes a separate item ready for individual upload.

  6. Context Merging: The Merge n8n node combines the attachment items (from Split Out) with the newly generated Folder ID (from Create Folder). This is vital because every file needs to know exactly where it should be uploaded.

  7. Final Upload: The Google Drive n8n node (Google Drive1) performs the final action. Using the dynamically retrieved Folder ID and the binary data name, it uploads each attached file directly into the designated, structured folder, completing the sophisticated n8n workflow.

Installation Guide

To implement this n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and paste it directly into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Credentials Setup: Locate the Gmail Trigger and both Google Drive n8n node components. You will need to set up or select existing OAuth2 credentials for:

Gmail: Ensure the account has permission to read emails and download attachments.
Google Drive: Ensure the account has permission to create folders and upload files.

  1. Activation: Once credentials are set for every n8n node, save the n8n workflow and toggle the 'Active' switch to enable the Gmail Trigger polling mechanism.

  2. Testing: Send an email with an attachment to the monitored Gmail account to verify the n8n template executes correctly and creates the structured folder in Google Drive.

Node Details

Gmail Trigger: This is the starting n8n trigger. It listens for new emails (polls every minute) and is configured to downloadAttachments: true to initiate the process.
Filter (n8n node): Checks for the existence of binary data ($binary) to ensure the n8n workflow only proceeds when an attachment is present, reducing unnecessary runs.
Gmail1 (n8n node): Performs a Get operation on the message ID received, often used here to consolidate binary data presentation before splitting.
Create Folder (Google Drive n8n node): Key configuration involves setting the Resource to Folder and dynamically naming the folder using an expression that pulls the email subject and current timestamp (=Motion - {{ $node["Gmail Trigger"].json.subject || "Untitled" }} - {{ $now }}).
Split Out (n8n node): Splits multi-attachment emails into separate items, ensuring each file is handled individually during the upload phase.
Merge (n8n node): Uses the combineAll mode to attach the newly created folder ID context to every individual attachment item.


  • Google Drive1 (n8n node): Configured for Upload File. It uses the Folder ID from the Create Folder n8n node output and uploads the binary file content.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

I’m passionate about using n8n to create realistic workflows that help working class people simplify their daily tasks. My workflows aim to make life easier by eliminating mundane, repetitive responsibilities that take up valuable time. I love turning automation into a tool that lets people focus on what matters most to them.

Featured*