How to check if a folder exists?

Describe the problem/error/question

I made a mock up workflow, the goal is to check if the cbz file contains a folder when extracting. If a folder exists then enter the folder path. How can I check if a folder exists since I don’t know the folder name?

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • **n8n version:1.89.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

Espero que esteja bem @Ruriko

tar -zxvf …: This is the gist of it.
.cbz files are renamed .zip files. Using tar may work in some cases if your tar system has zip support, but it is not the default or most reliable tool for .zip/.cbz files. The correct tool is unzip.
The -v (verbose) option is useful because it lists the extracted files.

In the output you are trying to get stderr (standard error output). The list of successfully extracted files usually goes to stdout (standard output).

In the Edit Fields (Set) node you try to split stderr by newline, because I think the list of files will probably be on stdout.

Hope this helps in some way

If this suggestion solved your problem, please mark my post as the solution (blue box with check mark) so that this ongoing discussion does not distract others who want to find the answer to the original question and click the heart. Thanks

There’s nothing wrong in my workflow. What I want to know is how can I check if the extracted file contains a folder. I’d assume i’ll need to use the IF node but I don’t exactly know what to use as a condition for checking if folder exists

Thanks for mentioning this.

Have you ever considered using a Function node before the IF node because that node would execute (iterate, extract, compare) and return a simple result.

Using an IF node after the Function node simply checks the boolean result returned by the Function node.

What do you think about this?

I’m not an experienced coder so I don’t know how to write a function for checking. Could someone write up a function?

If there is any part in Portuguese, translate it into your language, because I am Brazilian and I do not speak English, so I need to translate your question, understand what you need, see if I can help in any way, then answer, translate it into your language and then post it in the community.

Open a separate workflow to test the suggestion below OK.

1 Like

If this suggestion solved your problem, please mark my post as the solution (blue box with check mark) so that this ongoing discussion does not distract others who want to find out the answer to the original question and click the heart. Thank you :+1:

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