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
- Download the workflow file using the Download button on this page.
- Open n8n editor and select “Import from File” to upload the downloaded workflow.
Configure the workflow
- Add Google Drive API credentials in n8n if not already set up.
- Update the root folder ID and desired path in the Set node to your own folders.
Test the workflow
- Run the workflow manually by clicking “Execute Workflow” to check for errors.
Activate for production
- 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.
