Copy a directory from Google Drive

I’ve tried making this work but can’t get it to copy the directory. Im still new to Make so maybe its me. Anyone else had any luck?

Hi @Marcus,

What have you got so far?

You could use Google Drive - Search for Files/Folders to find the files in the folder you want to copy.
Just use * as the Query to get all the files.
You’ll receive a bundle for each result.

Then, you could use Google Drive - Copy a File module to copy each file to its new folder.

Thanks for the quick reply @Donald_Mitchell. I tried building out your solution but it still tries to locate one file and fails

The intent is to start a sequence that will automatically make a new folder on the drive and pull in another folder structure with multiple folders and files in it from another folder within the drive.

I ended up building out a solution where I created a module action for each folder and file (see below).

Surely there is a one module action to copy them all across. Not only to simplify the process but also to reduce operation cost usages. Yours would be 2 operations where as my current one is 8.

If you know, in advance, the names of the folders to be created, that’s probably a good way to go.

You still need to get the destination folders’ IDs, so once they’re created you will need those to copy files.

Google Drive seems to deal with file/folder IDs. Everything has an ID.

To save ops, you could probably save the source folder and file IDs so that you don’t have to get them from Google Drive every time and you’d know exactly how many of each you have so there’s no need for Make to waste Ops figuring it out.

Im at a dead end. Ive spent a couple of hours now trying so many permutations of it to no prevail.
This is really frustrating.
From looking online as well I can see that Google actually prevents you from copying entire folders over. Hence why my individual copying works, but the batch option doesn’t.
Could you get it working in the visual you showed above?

I managed to make a scenario that recursively calls itself to copy files and files within subfolders.

Overview

Here is a screenshot of how the scenario looks like:

As you can see, many API calls are needed to be made to fetch folder IDs and path names from folder IDs, and create the destination folder if it doesn’t exist.

However, this approach allows flexibility of the initial input and allows the scenario to also recursively call itself, as well as handle potential errors and resuming of errors.

Limitations

The only limitation I can think of is the scenario maximum run time, which is 5 minutes on the free plan, and 40 minutes on paid plans. If the folder structure you are trying to copy is very deep and has lots of subfolders, you may find that the scenario runs out of time.

On average, it takes up to 25 seconds to make a copy of the main folder, and 25 seconds for each subsequent subfolder. This is because the API call to fetch a folder ID by path is very slow.

Inputs

source

Can be either Folder Path (from the root of your drive), or Folder ID

dest

Can be either Folder Path (from the root of your drive), or Folder Name (placed in same directory-level as source folder)

Demo Run

Postman Screenshot

(it took about 52s since there is the main plus one subfolder)

Screenshot showing folder and subfolder copied too

(not shown in screenshot: one test file within the subfolder)

Conclusion / TL;DR

As you can see, it is possible to make a scenario that recursively copies an entire folder and it’s contents including subfolders. However, it may take a number of operations and may be slow since you need to reference and copy files and folders by ID, check if the source and destination folder exists, and if not create it, check if the scenario has the appropriate permissions to copy the files, handle errors, and provide appropriate webhook responses.

1 Like

Wow, nice job! This belongs in the Showcase :slight_smile:

3 Likes

I agree! Thanks for the detailed overview!