NextCloud: Avoid error by creating a folder that already exists

Hi Together

I’m using n8n to upload files to NextCloud. Before Uploading I’m creating with a node folder based on metadata (year-month) of the files.
When the first file is uploaded it works fine (when the folder doesn’t exist). But when a second, third … file is uploaded in the same folder, a error is raised by the nextcloud node, because the folder already exists.
How can I avoid this?
Kind regards
Daniel

Hi @colletda, welcome to the community!

The easiest way would be to simply ignore errors on the folder creation. You can do this by enabling the “Continue On Fail” option on your Nextcloud node:

A “cleaner” approach could be to build a logic that checks whether a folder already exists, for example like so:

On the first run, this workflow will create a folder with current year and month as its name:

When running for the second time, it would do nothing instead:

image

Hope this helps!

Thank you. This hints help me.
Kind regard
Daniel

1 Like

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