Recursive Google Drive Folder Duplication and Permission Preservation - n8n Workflow

Use this powerful n8n workflow to recursively duplicate Google Drive folders, ensuring all files, subfolders, and sharing permissions are preserved for perfect clones. Utilize this advanced n8n automation template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Markdown-formatted string. System administrators needing to clone project folders while maintaining access control lists (ACLs). Users requiring advanced n8n templates for cloud storage management. Teams that need reliable backups of complex, deeply nested Google Drive structures. n8n automation specialists looking for a real-world example of recursive flow control using the Execute Workflow n8n node.

Overview

Managing large, complex folder structures in Google Drive can be challenging, especially when you need to clone an entire directory while ensuring that existing sharing settings are carried over. This specialized n8n workflow solves this problem by executing a deep, recursive copy.

Starting with simple configuration inputs, the automation processes the source folder level by level. It identifies files and folders separately, creates corresponding duplicates in the target location, and then uses the file metadata to recreate sharing permissions (excluding the original 'owner' role).

This robust n8n solution ensures complete duplication fidelity, making it ideal for creating project templates, archival copies, or performing permission-preserved migrations. It is a highly efficient and reliable n8n workflow built around native Google Drive operations.

How it Works

This n8n workflow operates in two main phases: Initialization and Recursive Processing.

1. Initialization


  1. Set Configuration: The n8n workflow starts by defining three key variables: the ID of the sourceFolderId (what you want to copy), the ID of the targetFolderId (where it should go), and the newFolderName.

  2. Create Main Folder: A new top-level folder is created in the destination Google Drive using the defined name.

  3. Start Recursive Processing: The workflow uses an Execute Workflow n8n node to call itself. This immediately begins the recursive phase, passing the original source folder ID and the newly created destination folder ID as inputs.

2. Recursive Processing


  1. Search Folder Contents: The current source folder is queried using a Google Drive n8n node to retrieve all nested files and subfolders, along with their metadata and permissions.

  2. Filter & Split: The items are split into two parallel paths: Files and Folders.

  3. File Path: Files are copied to the target folder (Copy File1). The original and new file IDs, along with original permissions, are prepared. An If n8n node checks if any permissions exist. If yes, a Code n8n node strips the 'owner' permission and prepares the data, followed by an Apply File Permission1 Google Drive n8n node to set the shares. Execution then continues to Level Completion.

  4. Folder Path: Subfolders are created in the target folder (Create Subfolder1). Similar permission checking and application logic is used for the folder.

  5. Recursive Call: After processing files and applying permissions for the current subfolder, the n8n workflow triggers the core of its logic: Recursive Call to Self. This Execute Workflow n8n node calls the entire process again, using the newly copied subfolder's ID as the next source, ensuring every nested level is duplicated. This powerful n8n template logic allows for unlimited recursion depth.

Installation Guide

Markdown-formatted string.


  1. Import the n8n Workflow: Copy the provided JSON data and import it directly into your n8n instance via the Workflows section (New > Import from JSON).

  2. Google Drive Credential Setup: This n8n workflow requires a Google Drive OAuth2 credential. Ensure your credentials have permissions for the scope https://www.googleapis.com/auth/drive to allow file creation, copying, and permission management.

  3. Configure Parameters: Open the first n8n node, Set Configuration. Update the three string fields:

sourceFolderId: The Google Drive ID of the folder you wish to clone.
targetFolderId: The Google Drive ID of the parent folder where the copy should be placed.
* newFolderName: The desired name for the duplicated main folder.

  1. Testing: Save the n8n workflow. Since this solution uses the Execute Workflow n8n node for recursion, run it manually by clicking 'Execute Workflow'. Monitor the execution log to ensure the recursive calls are initiating correctly.

Node Details

Markdown-formatted string. Set Configuration (n8n node - Set): Used to initialize crucial variables like source and target folder IDs, and the name of the new folder. This allows easy modification of the n8n workflow parameters. Create Main Folder (Google Drive): Creates the initial top-level folder based on the targetFolderId and newFolderName. Start Recursive Processing (n8n node - Execute Workflow): This is the initial entry point to the recursive loop. It calls the n8n workflow itself, passing the necessary IDs to the sub-execution. Search Folder Contents1 (Google Drive): Uses a query search method to find all items within the current folder ID, returning the id, name, mimeType, and permissions for subsequent processing. Filter Files Only1 / Filter Folders Only1 (n8n node - Filter): Core logic for splitting the returned list based on mimeType. This is essential for directing files to the copy path and folders to the creation/recursion path. Copy File1 (Google Drive): Handles the physical duplication of a file to the new folder ID specified by the receiving n8n node execution context. Prepare File Permissions1 / Prepare Folder Permissions1 (n8n node - Code): These critical code n8n nodes parse the complex JSON permission data, exclude the 'owner' role (which cannot be copied), and restructure the data items into the format required by the Google Drive Share operation. Apply File Permission1 / Apply Folder Permission1 (Google Drive): Performs the Share operation on the newly created file or folder, applying the filtered permissions to match the source structure.* Recursive Call to Self (n8n node - Execute Workflow): The recursive n8n trigger. After a subfolder is created and its permissions are applied, this node calls the entire n8n template again, diving one level deeper into the folder hierarchy until all paths are processed.

Related n8n Workflows

Free

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

Featured*