Way to Duplicate a Folder in Google Drive (Including Subfolders and Files)

Hi everyone,

I’ve been struggling to find an efficient and easy-to-setup way to duplicate an entire folder in Google Drive to a new location.

The folder I’m working with contains both files and subfolders, each with their own set of files.

I’ve spent the last couple of hours trying to get a list of the files and subfolders, but I’m unable to make it work as expected. I’m sure there’s a built-in function or feature for doing this, but I haven’t been able to figure it out.

Any help or guidance would be greatly appreciated!

Thanks in advance!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Here’s my current approach:

  1. Retrieve the file & folder list from the root folder, including mimeType to distinguish between files and folders.
  2. If it’s a file, copy it directly to the corresponding new folder.
  3. If it’s a folder, retrieve its contents:
  • If it contains only files, copy them while preserving the subfolder path.
  • If it contains another folder, apply the same logic recursively.
  1. Repeat this process until all items have been processed.

The problem is that this method feels overly complicated, and I’m struggling with the loop logic—especially handling recursion efficiently. I suspect there’s a much simpler way to do this, but I haven’t figured it out yet.

Ideally, I need a dynamic approach that allows me to easily add files or subfolders in my root folder without modifying the workflow structure.

Has anyone tackled this before?

Thanks in advance! :blush:

There appears to be no API method to do this - this option is also not present in the user interface. You’ll just have to create a new folder and then loop through the files, copying them one by one, which shouldn’t be too hard with our Google Drive node?