Automate Nested Google Drive Folder Creation with n8n

Managing nested folder structures in Google Drive can be time-consuming and error-prone. This n8n workflow automates the creation of multi-level Google Drive folders from a simple path string, saving you hours and reducing manual errors.
googleDrive
code
if
+4
Workflow Identifier: 2131
NODES in Use: ManualTrigger, Set, Code, ExecuteWorkflowTrigger, If, GoogleDrive, StickyNote

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow creates nested folders in Google Drive automatically.

It solves the problem of making many folders one by one, which is slow and can cause mistakes.

The final result is a full folder path created or found, returning the deepest folder’s ID.

Who should use this workflow

People who manage lots of files on Google Drive and need to create folders regularly.

It is for anyone wanting to save time and avoid mistakes in folder creation.

Tools and services used

  • n8n: Automation platform to build workflows.
  • Google Drive API: To list, find, and create folders.

Inputs, processing steps, and output

Inputs

  • Root Google Drive folder ID (like “root” for main Drive).
  • Full desired folder path as a string, separated by slashes (example: Projects/Clients/Reports).

Processing steps

  • The path string is split into individual folder names.
  • For each folder name, the workflow checks if it exists inside the current parent folder.
  • If a folder does not exist, it creates the folder in Google Drive.
  • The parent folder ID updates to the newly created or found folder ID for the next step.
  • This process repeats until the full path is processed.

Output

  • The ID of the last (deepest) folder created or found in Google Drive is returned.

Beginner step-by-step: How to use this workflow in n8n

Import the workflow

  1. Download the workflow file using the Download button on this page.
  2. Open n8n editor and select “Import from File” to upload the downloaded workflow.

Configure the workflow

  1. Add Google Drive API credentials in n8n if not already set up.
  2. Update the root folder ID and desired path in the Set node to your own folders.

Test the workflow

  1. Run the workflow manually by clicking “Execute Workflow” to check for errors.

Activate for production

  1. Once happy with how it works, toggle the workflow to active to let it run automatically.

For users running self hosting n8n, see self-host n8n for deployment tips.

How the workflow works in detail

Step 1: Manual trigger

Starts the workflow execution manually or by external calls.

Step 2: Set input parameters

Uses a Set node to provide the starting folder ID and the path string.

Step 3: Split path

A Code node splits the path string into array of folder names.

Step 4: Prepare data

Another Code node passes the current folder ID and folder array forward.

Step 5: Check folder existence

The Google Drive node lists folders under the current parent to find the next folder.

Step 6: Decision check

An If node decides whether the folder exists or needs to be created.

Step 7: Create folder if missing

If missing, a Google Drive node creates the new folder under the current parent.

Step 8: Setup for next folder

A Code node updates the folder array and folder ID for the next iteration.

Step 9: Loop control

An If node checks if all folders are processed or to loop back for next folder.

Step 10: Output final folder ID

A Set node returns the ID of the last folder created or found.

Customization ideas

  • Change root folder ID in the input Set node to create folders inside another folder.
  • Add prefixes or suffixes to folder names in the Create new subfolder node for naming conventions.
  • Return extra folder details like creation date or URL by updating the final Set node.
  • Adapt the workflow to accept multiple folder paths in batch and loop over them.

Common edge cases and errors

  • If Google Drive node returns authentication errors, it usually means the OAuth2 credentials need reauthorization.
  • If folder creation does not work or layers are missing, check if the workflow correctly passes folder IDs and arrays between nodes.
  • Using debug nodes inside n8n can help inspect variable values at each step.

Summary of benefits

✓ Saves time by automating nested folder creation.

✓ Prevents errors caused by missing or misplaced folders.

✓ Returns the exact folder ID for use in other workflows.

✓ Can be reused as a sub-workflow in larger automations.


Frequently Asked Questions

The workflow splits a full folder path into parts, checks if each folder exists under the current parent, and creates missing folders step-by-step until the full path is made.
The workflow requires a root Google Drive folder ID to start from, and a string containing the full desired nested folder path separated by slashes.
If a folder exists, the workflow skips creating it and uses its ID to check or create the next folder in the path.
The base workflow handles one path at a time. To create multiple paths, it must be modified to loop over an array of paths.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free