← All N8N workflows
Automation & utilitiesCodeExecute Workflow TriggerIfManual TriggerNext Cloud

Get all files of subfolders

Configured with Execute Workflow Trigger, Next Cloud, Loop Over Items, Stop And Error, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TriggerWhen clicking "ExecuteWorkflow"Manual TriggerRoutingWhether type is fileIfTransformSet new path forsubfolderEdit FieldsCodeSet new path for fileCodeTriggerWebhookWebhookTriggerExecute WorkflowTriggerExecute Workflow TriggerTransformSet folder-paths forfrom and toEdit FieldsIntegrationCreate to folder ifnecessaryNext CloudIntegrationGet all folders/filesin from-folderNext CloudRoutingLoop over files andfoldersLoop Over ItemsRoutingConsolidate all filesand folders foundNo OpIntegrationCreate subfolder into-folderNext CloudIntegrationGet all folders/filesin found subfolderNext CloudRoutingWhether there is aremore files or…IfCodeConsolidate all foundfilesCodeRoutingLoop Over all filesLoop Over ItemsIntegrationMove file todestinationNext CloudIntegrationDelete from-folderNext CloudTransformSet pathsEdit FieldsRoutingWhether the request isvalidIfRoutingStop and Error: requestnot validStop And ErrorRoutingWhether the request isvalid1IfRoutingStop and Error: requestnot valid1Stop And Error

Node categories in this workflow

  • Trigger
  • Routing
  • Transform
  • Code
  • Integration

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
When clicking "Execute Workflow"TriggerManual TriggerSee node parameters
Whether type is fileRoutingIfSee node parameters
Set new path for subfolderTransformEdit FieldsSee node parameters
Set new path for fileCodeCodeSee node parameters
WebhookTriggerWebhookSee node parameters
Execute Workflow TriggerTriggerExecute Workflow TriggerSee node parameters
Set folder-paths for from and toTransformEdit FieldsSee node parameters
Create to folder if necessaryIntegrationNext Cloudfolder
Get all folders/files in from-folderIntegrationNext Cloudfolder / list
Loop over files and foldersRoutingLoop Over ItemsSee node parameters
Consolidate all files and folders foundRoutingNo OpSee node parameters
Create subfolder in to-folderIntegrationNext Cloudfolder
Get all folders/files in found subfolderIntegrationNext Cloudfolder / list
Whether there is are more files or subfolders foundRoutingIfSee node parameters
Consolidate all found filesCodeCodeSee node parameters
Loop Over all filesRoutingLoop Over ItemsSee node parameters
Move file to destinationIntegrationNext Cloudmove
Delete from-folderIntegrationNext Cloudfolder / delete
Set pathsTransformEdit FieldsSee node parameters
Whether the request is validRoutingIfSee node parameters
Stop and Error: request not validRoutingStop And ErrorSee node parameters
Whether the request is valid1RoutingIfSee node parameters
Stop and Error: request not valid1RoutingStop And ErrorSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • nextCloudApi

Workflow notes

Get all files of subfolders

Get all files of subfolders

In this segment of the workflow, all files located within subfolders are collected. This includes the exploration of subfolders within subfolders, ensuring the identification of every file throughout the entire folder structure. Additionally, a corresponding folder is created in the destination structure for each identified subfolder.

Enrich the files

Enrich the files

In this phase of the workflow, all identified files are processed and enriched with the correct path within the destination structure.

Move files

Move files

In this stage of the workflow, the files are moved into the destination structure.

If the batch size remains at 1 in the Loop Over node, each file will be moved sequentially. If the batch size is increased, multiple files will be moved simultaneously.

Get the files and subfolders to move

Get the files and subfolders to move

In this segment of the workflow, all files and subfolders to be relocated are gathered. Additionally, the destination folder is created if it does not already exist.

Manual Start

Manual Start

To manually initiate the workflow, the Set Paths node requires the specification of the folder path to be moved and the destination folder path. Subfolders can be indicated using '/'.

Ensure that the other workflow triggers are deactivated before initiating the workflow.

Webhook trigger

Webhook trigger

You can also automate the workflow by configuring a webhook to trigger it. It is crucial that each request contains a JSON body with at least the two attributes 'from-path' and 'to-path' set. Here is an example:

{
 "from": "Folder/to/move",
 "to": "New-Folder"
}

The workflow will respond with an error, if the request is not valid.

Ensure that the other workflow triggers are deactivated before initiating the workflow.

Trigger by other workflow

Trigger by other workflow

It is also possible to initiate this workflow from within another workflow. It is important to ensure that at least the 'from-path' and 'to-path' are passed as parameters when starting this workflow.

The workflow will respond with an error, if the request is not valid.

Ensure that the other workflow triggers are deactivated before initiating the workflow.

Template Description

Template Description

Description:

This template facilitates the transfer of a folder, along with all its files and subfolders, within a Nextcloud instance. The Nextcloud user must have access to both the source and destination folders. While Nextcloud allows folder movement, complications may arise when dealing with external storage that has rate limits. This workflow ensures the individual transfer of each file to avoid exceeding rate limits, particularly useful for setups involving external storage with rate limitations.

How it works:

  • Identify all files and subfolders within the specified source folder.
  • Recursive search within subfolders for additional files.
  • Replicate the folder structure in the target folder.
  • Individually move each identified file to the corresponding location in the target folder.

Set up steps:

  • Set Nextcloud credentials for all Nextcloud nodes involved in the process. -Edit the trigger settings. Detailed instructions can be found within the respective trigger configuration.
  • Initiate the workflow to commence the folder transfer process.

Help

If you need assistance with applying this template, feel free to reach out to me. You can find additional information about me and my services here. => https://nicokowalczyk.de/links

I have also produced a video where I explain the workflow and provide an example. You can find this video over here. https://youtu.be/K1kmG_Q_jRk

Cheers. Nico Kowalczyk

Get all files of subfolders

Get all files of subfolders

Purpose and structure

This folder contains the Get all files of subfolders workflow. Its executable nodes use code, executeWorkflowTrigger, if, manualTrigger, nextCloud, noOp, set, splitInBatches, stopAndError, webhook. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

When clicking "Execute Workflow", Webhook, Execute Workflow Trigger

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Stopanderror/0333_Stopanderror_Webhook_Create_Webhook.json MIT; preserve source notices.

Canvas section labels

These name areas of the original canvas; they do not include explanatory instructions.

  • (Optional) Delete *from*-folder

More in Automation & utilities