Hi, I’d like to breifly share my scenario that I created to copy a google drive template folder with all its subfolders.
Google drive doesn’t have option to copy folders. There are some tools out there. I based my method off this article he has a great tool for manual duplications.
Outline of method:
- Get the source folder and the destination folder
- Make a new folder with the same name as the source folder in the destination folder
- List all the files in the source folder, copy them, and move them to the new folder you created
- List all the folders in the source folder
- For folder you listed, run this process for each one.
So, the difficulty I encountered was how to implement recursion (step 5). Since the template folder has unknown levels of subfolders, how do we setup a scenario to repeat for every new subfolder it finds in the template directory?
I thought of the repeat module, thinking I can setup a loop of actions, and create a router with filter before the repeat to drop out and exit the loop whenever a condition is met (no more subfolders).
But its insufficient for this task, since the repeat value cannot be changed once initiated, that is, even if you pass in a var, once the repeat module starts, the var won’t update, since the repeat doesn’t actually execute the modules before and update its input.
Before giving up, I found another community article which was the aha moment. Use a webhook and HTTP!! uh why didn’t I think of that?!
In short, start with a webhook, create the workflow modules, then at the end use HTTP to call the webhook again (passing in new results), this will run the whole thing again. Now, just implement a filter to stop the HTTP from running infinitely. (I didn’t need to implement a filter in the end, since the 3rd module from scenario 2 would return 0 results, it won’t iterate anything, and the http won’t get called again).
See attached images with the 2 scenarios. If you’d like me to share anything else, please comment.
Scenario 2 (recursive)