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!
Retrieve the file & folder list from the root folder, including mimeType to distinguish between files and folders.
If it’s a file, copy it directly to the corresponding new folder.
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.
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.
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?