Skip to main content

Google Drive workflow with nested folder support

Workflow preview

Workflow preview
100%
Google Drive workflow with nested folder support preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Who’s it for Anyone who needs to recursively fetch all files from a specific Google Drive folder, including files inside all its nested (child) folders. Ideal for automation builders , admins , ...

Best for

  • File Management automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.if, n8n-nodes-base.stickynote, n8n-nodes-base.executeworkflowtrigger, n8n-nodes-base.code, n8n-nodes-base.set, n8n-nodes-base.executeworkflow, n8n-nodes-base.googledrive, n8n-nodes-base.splitinbatches

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Zain Ali.

Original n8n.io source

1.1 Workflow description

Title
Google Drive workflow with nested folder support
Workflow name
Google Drive workflow with nested folder support

👤 Who’s it for

  • Anyone who needs to recursively fetch all files from a specific Google Drive folder, including files inside all its nested (child) folders.
  • Ideal for automation builders, admins, and integrators who want to process, move, list, or report on all files in a complex folder tree.

⚙️ How it works / What it does

This workflow will:

  1. Accept a Google Drive Folder ID as an input (from another workflow or trigger).
  2. Recursively discover all child folders starting from the parent, no matter how many levels deep.
  3. Collect all file IDs & names from every folder (parent + all descendants).
  4. Return a clean list of all found files (with IDs and names) for further automation, downloading, or processing.

Key features:

  • 💡 Works recursively (handles any depth of nested folders).
  • 🏷️ Outputs file ID & file name for each discovered file.
  • 🔄 Can be triggered by other workflows (great for modular automation).

🛠️ How to set up

1. Google Drive Credentials
  • Make sure you’ve set up a Google Drive OAuth2 credential in n8n.
  • Connect this credential to all Google Drive nodes in the workflow.
2. Parent Folder ID
  • Input the Google Drive folder ID you want to start from.
  • How to pass it:
    • If running standalone: update the When Executed by Another Workflow node with your folder ID.
    • If called from another workflow: pass the folder ID as an input named id.
3. Check Set Nodes
  • There are two Set nodes (Return parent and Return parent1) and one trigger (When Executed by Another Workflow) where you might want to update the hardcoded folder ID.
  • ⚠️ Change these IDs to match your use case.
4. Run the Workflow
  • Start the workflow (or execute it via another workflow).
  • The result will be a flat list of files in all subfolders.

✅ Requirements

  • 🟢 n8n instance
  • 🟢 Google Drive OAuth2 credentials connected in n8n
  • 🟢 A valid Google Drive folder ID to start from

🧑‍💻 How to customize

  • Return Extra Data:
    Add fields in the “Search files” node options to return more Google Drive file metadata (e.g., size, webViewLink).
  • Filter by File Type:
    Adjust the search query or add a filter node to only include certain file types (e.g., PDFs, Docs).
  • Change Output Format:
    Edit the “Edit Fields” Set node to structure your output differently.
  • Integrate Further:
    Add new nodes after the Loop to, for example, download, email, or sync files as needed.

🚨 Notes & Tips

  • Performance:
    This workflow is optimized for up to hundreds of folders. For very large Drive accounts (thousands of folders/files), consider pagination or batching.
  • Credential Security:
    Always use n8n’s built-in credential manager—never hard-code sensitive data.
  • Static IDs:
    As noted in the sticky note, make sure to update all hardcoded folder IDs for your production use.

🗂️ Node Overview

  • When Executed by Another Workflow: Accepts a folder ID (entry point).
  • Google Drive – Get children folders: Lists subfolders of the given folder.
  • If: Checks if the folder contains any subfolders.
  • Execute Workflow: Handles recursion (calls itself on child folders).
  • Code: Flattens all discovered folder IDs for next step.
  • Loop Over Items: Iterates over all folders to process files.
  • Google Drive – Search files: Finds all files in each folder.
  • Edit Fields (Set): Structures file data for output.
  • Sticky Note: Documentation and reminders inside your workflow.

🔄 Example Output

[
  {
    "file_id": "1A2B3C...",
    "file_name": "MyDoc.pdf"
  },
  {
    "file_id": "2B3C4D...",
    "file_name": "Presentation.pptx"
  }
]

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - If parent folder has no folder

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 2 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - If parent folder has nested folders or not

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 4 - Start Execution

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 5 - Get all folder ids

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 6 - Return parent folder id

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 7 - Return parent folder id to sub-workflow

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 8 - Start sub-execution

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 9 - Get children folders from folder id

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 10 - Loop Over folder ids

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 11 - Get all files inside a folder

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 12 - Return all file ids

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Google Drive workflow with nested folder support
Complexity intermediate
Nodes 14
Categories File Management
Author Zain Ali
Published 23 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6320/6320.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Google Drive workflow with nested folder support do?

Who’s it for Anyone who needs to recursively fetch all files from a specific Google Drive folder, including files inside all its nested (child) folders. Ideal for automation builders , admins , ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your File Management use case.