Get all subfolders - Onedrive

Hey Guys n Dolls,

First post and new to n8n here. So be gentle.

But now to the question:
I am trying to fetch the folder-structure of a OneDrive Folder, with many many subfolders for further parsing by an AI-Agent. The Main OneDrive-Node doesn’t seem to do that, It only fetches the children of the first Folder, so I am trying to create some kind of loop that feeds all the subfolders into the Get-Children-Node one after another to then have a list of all the Folders, their paths and their OneDrive-IDs.
Now I don’t get the right Idea on how to replace the main Folder ID with new ones for the subfolders one per one and to

I’m not getting any Error, but not the wanted result.

The Picture is the first version that I tried, now I tried a different approach which I attached as a worklflow:

I’m kinda Lost, but I think there is just this tiny little detail that I’m not aware of…

Thanks a lot :slight_smile:

Information on your n8n setup

  • **n8n version:1.85.4 **
  • Database: none
  • n8n EXECUTIONS_PROCESS setting: Manual
  • Running n8n via: npm
  • Operating system: Win 11 Pro

Little Update:
I got a little further by simply doing what you’ll see down below. But now it just passes through the loop for two times and then stops… But Maybe someone knows if I am on the right track?

Switching the two nodes around already helped, so that the first folder i scanned completely und the first subfolder also, but then it stops…

hello @JulienBlue

The approach is the same as was in this thread (but in your case it will be a folder id instead of the github path):

You will need a sub workflow which will executes itself for every folder id you have in the parent folder

1 Like

Thank you very much! Will look into that :slight_smile:

So… I fiddled around but am not getting to the end…
I took your example and adjusted it to onedrive and I’m getting how it should work. The problem is now, that I can’t get the sub-workflow to take the fields from the main-workflow.
Maybe there was an update since your version, but I can’t specify the output-fields from the, only the input-field from the sub.

Message in Main-Execute Workflow:
This sub-workflow will consume all input data passed to it. You can define specific expected input in the [sub-workflow’s trigger]

Should not be a problem, but when I specify id & path, it doesn’t pull the data from main, only null.

Also tried “accept all data” in the sub-start-node, but then I only get:

[
{
}
]

I haven’t gotten to the point after “get- subchildren” so please ignore that.

You have any idea on why I won’t get the data from main to sub?

Thanks :slight_smile:

your Execute workflow in the main WF should have proper inputs set

And don’t use the old Set node, it’s too old…

You can also disable the Execute Workflow node in the sub workflow to check that the sub WF is working. Wihtout triggering the possible infinite loop :sweat_smile:

I just ran an update et voilà, i can set the workflow-inputs. But its still not working so i slimmed everything down just to understand how to pass data to the next node but I still don’t get it :sob:

I detached the workflow from the Sub-Start just to see whats “arriving” but it’s still null… Slowely I feel like a null myself :expressionless:

What the flowers am I missing? So sorry to bother you…

Can you provide the output of the Get Children Node? I don’t have oneDrive to test

Of Course:

I think you have everything you need in the Screenshots.
The ID which is used to get children in a OneDrive-Node is the first one, in that case “94F1CF51181F044F!6714”
It’s also correclty taken over to the execute Sub-Node as you can see in the screenshot, where you can also see, that it is correclty fetching the different IDs for the different Folders. Then it’s only spitting out the Input, cause I detached the Sub-WF-Start from the performing part, because it’s failling due to a missing ID for the “Get Children”-Part in that.

The Main WF is also correclty updating the Workflow Inputs as I change them in the Sub-WF and refresh them in the Main-WF. So the connection between the two seems to be working.

Main-WF- Execute Sub - Node

Sub-WF - Start-Node

Is that everything you need?

How did you get the output of the sub-workflow? Did you press the View sub-execution link or manually clicked on the “Test Step” button of the trigger?

I clicked it manually… I didn’t get that there is a difference… Thank you!!!
I feel stupid now :nerd_face:
But THANKS!!!

I will post my last result, when I’m done :slight_smile:

yes, Test Step will only evaluates the variables to null. It doesn’t run the parent workflow.

Hello Again,
Got back to it today, and made “some” progress, but the recursive self execution is not working.

The “Fetch Chirldren PRESET” node is just for testing, and is only executed once when connected.

After going through to the execute self node the fetch children Node is beeing executed but fails due to “Execute” giving out null as an ID. but in “Execute Self” I think that I have correctly set to pass the ID, besides the path and a boolean processed flag

I got that it gives out null while “testing workflow”, but how can I test if it works if it only gives out null?

When I run the main Flow, with the preset disconnected and saved, I only get 10 folders, but it should be 31.

Thanks in advance :slight_smile:

Are you sure it’s 10? because 10 is the default amount to output and if you copy the output, you will copy only 10 items from it (unless you set the different page size)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.