Skip to main content

Template-based Google Drive folder generation with Forms and Apps Script

Workflow preview

Workflow preview
100%
Template-based Google Drive folder generation with Forms and Apps Script preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Stop manually creating folder structures for every new client or project. This workflow provides a simple form where users enter a name, and automatically duplicates your template folder structure ...

Best for

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

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.formtrigger, n8n-nodes-base.googledrive, n8n-nodes-base.wait, n8n-nodes-base.httprequest

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Template-based Google Drive folder generation with Forms and Apps Script
Workflow name
Template-based Google Drive folder generation with Forms and Apps Script

Overview

Stop manually creating folder structures for every new client or project. This workflow provides a simple form where users enter a name, and automatically duplicates your template folder structure in Google Drive—replacing all placeholders with the submitted name.

What This Workflow Does

  1. Displays a form where users enter a name (client, project, event, etc.)
  2. Creates a new main folder in Google Drive
  3. Calls Google Apps Script to duplicate your entire template structure
  4. Replaces all {{NAME}} placeholders in files and folder names

Key Features

  • Simple form interface — No technical knowledge required to use
  • Recursive duplication — Copies all subfolders and files
  • Smart placeholders — Automatically replaces {{NAME}} everywhere
  • Production-ready — Works immediately after setup

Prerequisites

  • Google Drive account with OAuth2 credentials in n8n
  • Google Apps Script deployment (code below)
  • Template folder in Drive using {{NAME}} as placeholder

Setup

Step 1: Create your template folder

📁 {{NAME}} - Project Files
├── 📁 01. {{NAME}} - Documents
├── 📁 02. {{NAME}} - Assets
├── 📁 03. Deliverables
└── 📄 {{NAME}} - Brief.gdoc

Step 2: Deploy Apps Script

  1. Go to script.google.com
  2. Create new project → Paste code below
  3. Deploy → New deployment → Web app
  4. Execute as: Me | Access: Anyone
  5. Copy the deployment URL

Step 3: Configure workflow Replace these placeholders:

  • DESTINATION_PARENT_FOLDER_ID — Where new folders are created
  • YOUR_APPS_SCRIPT_URL — URL from Step 2
  • YOUR_TEMPLATE_FOLDER_ID — Folder to duplicate

Step 4: Test Activate workflow → Open form URL → Submit a name → Check Drive!


Apps Script Code

function doPost(e) {
  try {
    var params = e.parameter;
    var templateFolderId = params.templateFolderId;
    var name = params.name;
    var destinationFolderId = params.destinationFolderId;
    
    if (!templateFolderId || !name) {
      return jsonResponse({
        success: false,
        error: 'Missing required parameters: templateFolderId and name are required'
      });
    }
    
    var templateFolder = DriveApp.getFolderById(templateFolderId);
    
    if (destinationFolderId) {
      var destinationFolder = DriveApp.getFolderById(destinationFolderId);
      copyContentsRecursively(templateFolder, destinationFolder, name);
      
      return jsonResponse({
        success: true,
        id: destinationFolder.getId(),
        url: destinationFolder.getUrl(),
        name: destinationFolder.getName(),
        mode: 'copied_to_existing',
        timestamp: new Date().toISOString()
      });
    } else {
      var parentFolder = templateFolder.getParents().next();
      var newFolderName = replacePlaceholders(templateFolder.getName(), name);
      var newFolder = parentFolder.createFolder(newFolderName);
      copyContentsRecursively(templateFolder, newFolder, name);
      
      return jsonResponse({
        success: true,
        id: newFolder.getId(),
        url: newFolder.getUrl(),
        name: newFolder.getName(),
        mode: 'created_new',
        timestamp: new Date().toISOString()
      });
    }
  } catch (error) {
    return jsonResponse({
      success: false,
      error: error.toString()
    });
  }
}

function replacePlaceholders(text, name) {
  var result = text;
  result = result.replace(/\{\{NAME\}\}/g, name);
  result = result.replace(/\{\{name\}\}/g, name.toLowerCase());
  result = result.replace(/\{\{Name\}\}/g, name);
  return result;
}

function copyContentsRecursively(sourceFolder, destinationFolder, name) {
  var files = sourceFolder.getFiles();
  while (files.hasNext()) {
    try {
      var file = files.next();
      var newFileName = replacePlaceholders(file.getName(), name);
      file.makeCopy(newFileName, destinationFolder);
      Utilities.sleep(150);
    } catch (error) {
      Logger.log('Error copying file: ' + error.toString());
    }
  }
  
  var subfolders = sourceFolder.getFolders();
  while (subfolders.hasNext()) {
    try {
      var subfolder = subfolders.next();
      var newSubfolderName = replacePlaceholders(subfolder.getName(), name);
      var newSubfolder = destinationFolder.createFolder(newSubfolderName);
      Utilities.sleep(200);
      copyContentsRecursively(subfolder, newSubfolder, name);
    } catch (error) {
      Logger.log('Error copying subfolder: ' + error.toString());
    }
  }
}

function jsonResponse(data) {
  return ContentService
    .createTextOutput(JSON.stringify(data))
    .setMimeType(ContentService.MimeType.JSON);
}

Use Cases

  • Agencies — Client folder structure on new signup
  • Freelancers — Project folders from intake form
  • HR Teams — Employee onboarding folders
  • Schools — Student portfolio folders
  • Event Planners — Event documentation folders

Notes

  • Apps Script may take +60 seconds for large structures
  • Timeout is set to 5 minutes for complex templates
  • Your Google account needs edit access to template and destination folders

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 - Main Overview

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

Block 2 - Warning - Apps Script

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

Block 3 - Section 1

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

Block 4 - Section 2

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

Block 5 - Section 3

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

Block 6 - Folder Request Form

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

Block 7 - Create Main Folder

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

Block 8 - Wait for Drive

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

Block 9 - Duplicate Template

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

3. Summary Table

Workflow Template-based Google Drive folder generation with Forms and Apps Script
Complexity intermediate
Nodes 9
Categories File Management
Author Antonio Gasso
Published 10 Dec 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/11663/11663.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 Template-based Google Drive folder generation with Forms and Apps Script do?

Stop manually creating folder structures for every new client or project. This workflow provides a simple form where users enter a name, and automatically duplicates your template folder structure ...

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.