While backing up n8n flows to Github, how to detect the (virtual) folders?

I’m using a flow to automatically backup the flows to Github.

I’m also using folders to store the flows.

However, all flows are stored in the same folder on Github, and I can’t find the folder names in the flow data.

I can see that each flow has a unique id: however in Github flows are stored by name and having two flows named identically in different folders results in overwriting flows.

So: how to detect the folders and store the flows in Github in the exact same folder structure?

Information on your n8n setup

  • n8n version: 1.92.1 / Custom container with Python
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker of course
  • Operating system: Not Relevant

afaik there is currently no information available in the workflow-data (using n8n API) to access the virtual folder information. I’ve created a workaround which pulls the folder-informations from n8n’s PostgreSQL-database and adds it to the workflow - so I can file my backups in a more structured way.

each workflow-JSON will have additional information like this

"folderName":  "foldername-from-n8n",
"parentFolderId":  "gTm356rik6AJa8NT",