Google Drive listing by batches?

Hi there, thanks for the great work with n8n!

For audit proceses, I’m trying to list all files, folders and subfolders within a google drive folder.

The way it works is the following:

  • read the ID of a folder
  • read the files and folders with that ID as a parent (by adding “folderId” in parent as a parameter for the query)
  • append or update the changes
  • iterate on the subfolders

So far, it iterates on the first subfolder that finds into every folder, but doesn’t follow into the other ones if there’s more than one folder into a subfolder.

It seems like I would need to split somehow the list of IDs from the folders, but I’ve not managed to achieve that.

Any suggestions?
Thank you very much!

Welcome to the community @rdgmar

Most of the nodes iterate depending on the number of inputs, but the Google Drive node with operation list:file is an exception. I would try something like the example below.

I think you need to set the splitInBatches batch size to 1?

This also gives you multiple executions on the last node that duplicate data. I’ve run into this a few times, and the only way I’ve found to effectively merge multiple executions is by calling the merge function once after all other functions have completed. In this case it doesn’t make visual sense because the function node Collate Files is not directly downstream of the data it’s collecting Get Files:

Ahh yes, good catch.

Thank you @RicardoE105 and @pemontto amazing speed to reply!

With the SplitInBatches node, I’ve managed to process the data, but I’m struggling to make the recursive loop that would traverse the folder tree.

I’m able to do it manually adding a several loops to the level of depth I want to go, but how can I generate a loop with nested splitinbatches nodes where I don’t know how deep can the tree become?

That’s a tricky one, and I can’t seem to get it working, probably a similar problem. I’ve tried multiple variations of fetching just the sub folders with split in batches, but it seems the split in batches only accepts the first execution, any subsequent recursion isn’t working for me. Quite likely I’ve got something wrong though. Here’s an example

BTW if you don’t need the hierarchy you can just try get files with a large limit and no query string?

Did you ever find a solution for this?