N
n8n Store
Workflow Market
Create folder in OneDrive

Create folder in OneDrive

by back2950 views

Description

Categories

🤖 AI & Machine Learning

Nodes Used

n8n-nodes-base.ifn8n-nodes-base.coden8n-nodes-base.splitOutn8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.splitInBatchesn8n-nodes-datastore.datastoren8n-nodes-datastore.datastoren8n-nodes-datastore.datastoren8n-nodes-datastore.datastore
PriceFree
Views0
Last Updated11/28/2025
workflow.json
{
  "id": "bfA4a1LwJVx6G5kB",
  "meta": {
    "instanceId": "b8e02da9da087e6be3a37f0784f0160a5508106e3fb771a8529df943289a5ec3",
    "templateCredsSetupCompleted": true
  },
  "name": "Create folder in OneDrive",
  "tags": [],
  "nodes": [
    {
      "id": "1b14115d-eca4-4439-9da0-3c3b0b054b0f",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -1088,
        576
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "folder"
            }
          ]
        }
      },
      "notesInFlow": false,
      "typeVersion": 1.1
    },
    {
      "id": "00258e85-bc24-4db6-9e6b-d95a7cdd1eef",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -416,
        576
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "paths"
      },
      "typeVersion": 1
    },
    {
      "id": "81016209-22fd-43e2-8dc6-5b3fa5b65b79",
      "name": "Paths",
      "type": "n8n-nodes-base.code",
      "position": [
        -864,
        576
      ],
      "parameters": {
        "jsCode": "const folder = $input.first().json.folder || \"Foobar/Barfur/Furbar\";\n\nreturn {\n  paths: folder.split('/').map((folder, index, arr) => ({\n    name: folder,\n    path: `/drive/root:/${arr.slice(0, index + 1).join('/')}`,\n    parentId: null,\n    parent: index === 0 ? \"/drive/root:\" : `/drive/root:/${arr.slice(0, index).join('/')}`\n  }))\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "4ecf8424-7677-489f-8e1a-e329b698591f",
      "name": "Search",
      "type": "n8n-nodes-base.microsoftOneDrive",
      "position": [
        32,
        304
      ],
      "parameters": {
        "query": "={{ $json.name }}",
        "resource": "folder",
        "operation": "search"
      },
      "credentials": {
        "microsoftOneDriveOAuth2Api": {
          "id": "vFXV2LMuV1uM3sI2",
          "name": "Microsoft Drive account"
        }
      },
      "notesInFlow": false,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "9df67617-bcca-4b67-bbbb-b5cf93de6d6a",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -192,
        576
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "56565cae-85ed-4925-a310-dffa82ce657d",
      "name": "Create a folder",
      "type": "n8n-nodes-base.microsoftOneDrive",
      "position": [
        672,
        704
      ],
      "parameters": {
        "name": "={{ $('Split Out').item.json.name }}",
        "options": {
          "parentFolderId": "={{ $json.value || null }}"
        },
        "resource": "folder",
        "operation": "create"
      },
      "credentials": {
        "microsoftOneDriveOAuth2Api": {
          "id": "vFXV2LMuV1uM3sI2",
          "name": "Microsoft Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fa1ed9a0-ecf6-43d7-8c93-6ecc379bae81",
      "name": "Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        192,
        304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "186ba457-5540-46bd-b582-7caf6173cfd1",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.id }}",
              "rightValue": ""
            },
            {
              "id": "8a0a1ee3-27c7-443b-bf9a-58528bf620d1",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.parentReference.path }}",
              "rightValue": "={{ $('Loop Over Items').item.json.parent }}"
            }
          ]
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": false
    },
    {
      "id": "bc711dd2-fde2-4ebb-9fb3-1c2f31f9e0dd",
      "name": "setParentFound",
      "type": "n8n-nodes-datastore.datastore",
      "position": [
        400,
        288
      ],
      "parameters": {
        "keyName": "parentID",
        "valueString": "={{ $('Search').item.json.id }}"
      },
      "typeVersion": 1
    },
    {
      "id": "ea2026e1-4913-4b4a-9866-8865de7998d8",
      "name": "setParentCreated",
      "type": "n8n-nodes-datastore.datastore",
      "position": [
        896,
        704
      ],
      "parameters": {
        "keyName": "parentID",
        "valueString": "={{ $json.id }}"
      },
      "typeVersion": 1
    },
    {
      "id": "f3c29938-238d-4297-80ac-a83ede402a76",
      "name": "getParent",
      "type": "n8n-nodes-datastore.datastore",
      "position": [
        448,
        704
      ],
      "parameters": {
        "keyName": "parentID",
        "operation": "get"
      },
      "typeVersion": 1
    },
    {
      "id": "4e3100f1-5d56-4560-8a32-c167f18aa842",
      "name": "clearParent",
      "type": "n8n-nodes-datastore.datastore",
      "position": [
        -640,
        576
      ],
      "parameters": {
        "keyName": "parentID",
        "operation": "clear"
      },
      "typeVersion": 1
    },
    {
      "id": "7fd2d1f9-7cf5-415b-a574-8f803edda11a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        592
      ],
      "parameters": {
        "width": 640,
        "height": 336,
        "content": "## Create folder if it does not exist\n\nPass the ID of created folder forward and store it"
      },
      "typeVersion": 1
    },
    {
      "id": "38a438a1-9d6e-45e5-a83c-849d6b10b030",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        144
      ],
      "parameters": {
        "width": 528,
        "height": 400,
        "content": "## Create a nested folder in Microsoft OneDrive\n\n- This workflow loops you nested folder e.g. `Foobar/Barfur/Furbar` and creates folders one by one if they don't exist\n- This is because OneDrive API call can do it only like that\n\n## Testing\n\n- \"Paths\" Node has a default value `Foobar/Barfur/Furbar`\n\n## Usage\n\n- Execute this workflow a Sub-workflow and pass your nested folder as `$folder` input variable"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7ee0fe9b-34e0-4d03-a775-3d2c83c4f9a3",
  "connections": {
    "Paths": {
      "main": [
        [
          {
            "node": "clearParent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Exists": {
      "main": [
        [
          {
            "node": "setParentFound",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "getParent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search": {
      "main": [
        [
          {
            "node": "Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getParent": {
      "main": [
        [
          {
            "node": "Create a folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "clearParent": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "setParentFound": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a folder": {
      "main": [
        [
          {
            "node": "setParentCreated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "setParentCreated": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

相关工作流