{
  "name": "Process multiple files with forms: a tutorial on binary data and loops",
  "nodes": [
    {
      "id": "be53d6d3-2416-482e-a714-4573fed4bfbb",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -440,
        -460
      ]
    },
    {
      "id": "699f5089-7416-414a-8e95-3bdb8637a6d9",
      "name": "Save Each File",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -240,
        -400
      ]
    },
    {
      "id": "c8c5f9e6-670b-405b-af1d-72eeb372303e",
      "name": "Split Out Files",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -780,
        -460
      ]
    },
    {
      "id": "8f7252ac-4082-49b8-9e56-9d14689ee864",
      "name": "Form - Load Multiple Files",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1220,
        -460
      ]
    },
    {
      "id": "72ee0e48-9a75-4c7d-af09-bcd5bbc5b2ba",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1400,
        -760
      ],
      "parameters": {
        "width": 1740,
        "height": 140,
        "content": "## Learning n8n\n### Loops, Multiple Binary Files, {{$runIndex}}\n\nLoops are rarely needed in n8n, but here is one example of how to effectively use one to process multiple binary files."
      }
    },
    {
      "id": "962e91d5-eb75-4245-9dfb-4b13c15cdb0a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1400,
        -600
      ],
      "parameters": {
        "width": 480,
        "height": 400,
        "content": "Use a Form to load multiple files. \n\nThis is a case where n8n will NOT fire an event per file loaded, but instead a single event with all files nested into 1 array. \nHowever, we want to process the fi"
      }
    },
    {
      "id": "2aee5134-abc4-45f9-a2db-cf205f18cff7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -600
      ],
      "parameters": {
        "width": 360,
        "height": 400,
        "content": "Split Out will fix this, firing one event for each file.\n\n*We must make sure to pass binary data along.*"
      }
    },
    {
      "id": "1ec83469-5dcd-4beb-9414-7f75a0727ed3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -600
      ],
      "parameters": {
        "width": 460,
        "height": 400,
        "content": "Now we can use a Loop to handle each file, one at a time.\nWith this setup, the special {{$runIndex}} can be used to get our loop counter.\n\nWe use it to get the correct binary file, which has been inco"
      }
    },
    {
      "id": "2545fa3e-346b-4277-b494-f1c2d469dceb",
      "name": "Continue Once",
      "type": "n8n-nodes-base.noOp",
      "position": [
        60,
        -480
      ]
    },
    {
      "id": "d1646761-2962-4afb-9033-d13f7d853290",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -600
      ],
      "parameters": {
        "width": 380,
        "height": 400,
        "content": "We typically only want to proceed downstream with a single event, so this NOP set to \"run once\" will let us do that regardless of the file count."
      }
    }
  ],
  "connections": {
    "Continue Once": {
      "main": [
        []
      ]
    },
    "Save Each File": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Continue Once",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save Each File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out Files": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form - Load Multiple Files": {
      "main": [
        [
          {
            "node": "Split Out Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}