Get list of subfolders

Describe the problem/error/question

I want to create a list of subfolders in a directory. I can see that the Read Files node can list files but it can’t list subfolders. Is there a node that can list subfolders?

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • **n8n version:**1.83.2
  • **Database (default: SQLite):**default
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):**default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**npm
  • **Operating system:**Windows Server 2022

Hi,

in worst cast you could do an “execute command” and list all the directories based on your OS.

The best would be to find a tool or CLI command that can output in a reasonable format so the subsequent parsing step would be easy.

reg,
J.

Hi @Ruriko, take a look at this solution, it might work for you.

So i’m using the execute command node but I don’t know how to transfer the data to n8n to output as json. How can I do this?

Can’t use that method since that only works for remote filesystem where as I want to do it on a local filesystem

1 Like

Hi,

I’ve created a slightly modified example.

The output is available through linux-style naming (stdout)

I’ve changed the dir command to be recursive so it fetches all the directories.

If you need to have only the relative paths, you will need to use a code node to transform it.

Please accept as a solution if it solved your problem.

regards,
J.

1 Like

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