Back to blog

How do I duplicate a Drive tree structure?

How do I duplicate a Drive tree structure?

Filling a Gap in Google Drive: The Folder Duplication Tool

Google Drive is a powerhouse for collaboration, yet it lacks a surprisingly basic feature: the ability to natively duplicate an entire folder and its internal structure in one click. To address this, a robust open-source add-on developed in Apps Script offers a professional solution.

Comprehensive and Customizable Duplication

Developed by Fabrice FAUCHEUX, this tool (currently version 2.1) allows users to clone complex folder structures directly within the Drive interface. It provides total control over the copying process with several key features:

  • Preview and Statistics: Before starting, the tool calculates the number of sub-folders, files, and the depth of the tree.
  • Content Options: Users can choose to replicate only the folder structure or include all files as well.
  • Flexible Destinations: Copies can be created in the same location, at the Drive root, or within a specific folder using its unique ID.
  • Exclusion Filters: Specific sub-folders can be ignored by entering their names.
  • Regex Support: For advanced users, regular expressions can be used to define complex exclusion rules.

Built for Large Volumes

Duplicating large structures often hits Google's execution time limits (set at 25 seconds per pass in this script). This tool intelligently bypasses this hurdle using a custom state-saving and "chunking" system.

If a task is too large to complete in one pass, the tool saves its progress. The user can then resume the duplication from exactly where it stopped, ensuring that even the most massive folder trees are eventually fully copied. Additionally, an automatic retry logic is integrated to handle temporary API or network errors.

Transparency and History

The add-on maintains a history of the last ten duplications, providing direct links to the newly created folders. Each entry includes the date, source/destination names, and the total count of items processed.

Technically, the tool utilizes Drive API v3 and is released under the GNU GPL v3 license, ensuring users have the freedom to inspect, modify, and share the source code.

Discover my AI tools

Explore the Gemotheque, generate optimized prompts for ChatGPT and Midjourney, or test my dedicated AI assistants.