AutomationFlowsData & Sheets › Load and Aggregate Files From a Google Drive Folder Into a Key-value Dictionary

Load and Aggregate Files From a Google Drive Folder Into a Key-value Dictionary

ByHugues Stock @hpstock on n8n.io

This workflow automates the process of retrieving all Google Docs from a specified Google Drive folder, extracting their content, and structuring the data into a unified key-value dictionary, where: Key = The file name Value = The content of the document (with normalized…

Event trigger★★★★☆ complexity8 nodesExecute Workflow TriggerGoogle DriveGoogle Docs
Data & Sheets Trigger: Event Nodes: 8 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #3421 — we link there as the canonical source.

This workflow follows the Execute Workflow Trigger → Google Drive recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Google Drive Files Loader",
  "nodes": [
    {
      "id": "3d066626-a87d-4e7b-bc16-9f47e1277dde",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "cb0e5563-1550-4121-9fd5-b1cbd9810476",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        0
      ],
      "parameters": {
        "jsCode": "// n8n Code Node\n\n// Initialize an empty object to store the aggregated results\nconst aggregatedDict = {};\n\n// Get all input items passed to this node\nconst inputItems = $input.all();\n\n// Loop through each input item\nfor (const item of inputItems) {\n  // Get the JSON data from the current item\n  const itemJson = item.json;\n\n  // Check if item.json is actually an object and not null/undefined\n  // Also ensure it's not an array, as we expect key-value pairs\n  if (itemJson && typeof itemJson === 'object' && !Array.isArray(itemJson)) {\n\n    // Iterate over all the keys within the current item's JSON object\n    for (const key of Object.keys(itemJson)) {\n      // Add/overwrite the key-value pair to our aggregated dictionary\n      aggregatedDict[key] = itemJson[key].replaceAll(/\\n+/g, \"\\n\");\n      // console.log(`Adding/Updating key: ${key}`); // Optional: for debugging\n    }\n\n  } else {\n    // Optional: Log a warning if an item doesn't have the expected format\n    console.warn(`Skipping item - 'json' property is not a valid object:`, itemJson);\n  }\n}\n\n// n8n expects an array of items as output.\n// We return a single item containing the final aggregated dictionary in its 'json' property.\nreturn [{ json: aggregatedDict }];"
      },
      "typeVersion": 2
    },
    {
      "id": "1b90ca95-7251-4573-9b0b-4af3622721ba",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -140
      ],
      "parameters": {
        "height": 300,
        "content": "## Step1\nDefine folder you want to search all files in."
      },
      "typeVersion": 1
    },
    {
      "id": "d26c2f27-0095-4dd6-9aa5-94c68f58bda3",
      "name": "Get files from folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        220,
        0
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "mode": "list",
            "value": "root",
            "cachedResultName": "/ (Root folder)"
          }
        },
        "options": {},
        "resource": "fileFolder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "938c8f7c-84b1-4eeb-a7c8-894ae5fbc275",
      "name": "Download Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        500,
        0
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "={{ $json.id }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "caa075a2-2e85-47e5-a829-425a1177e5be",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -140
      ],
      "parameters": {
        "height": 300,
        "content": "## Step2\nIf you have files other than google docs change node here."
      },
      "typeVersion": 1
    },
    {
      "id": "05db5439-584e-40aa-9c1d-101618f66fdc",
      "name": "Mapping",
      "type": "n8n-nodes-base.set",
      "position": [
        780,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b33e9355-659a-4b71-ba5c-00c90b7ed792",
              "name": "={{ $('Get files from folder').item.json.name }}",
              "type": "string",
              "value": "={{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "85dc7e65-7d50-4b13-b114-88b4020865e8",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -140
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 300,
        "content": "## Mapping\nThis mapping part will output a dictionary with key:value where key if file name and value is file content"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Mapping": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Google Docs": {
      "main": [
        [
          {
            "node": "Mapping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get files from folder": {
      "main": [
        [
          {
            "node": "Download Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Get files from folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow automates the process of retrieving all Google Docs from a specified Google Drive folder, extracting their content, and structuring the data into a unified key-value dictionary, where: Key = The file name Value = The content of the document (with normalized…

Source: https://n8n.io/workflows/3421/ — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

Gemini - Video Analysis. Uses googleDrive, googleDriveTrigger, executeWorkflowTrigger, httpRequest. Event-driven trigger; 17 nodes.

Google Drive, Google Drive Trigger, Execute Workflow Trigger +2
Data & Sheets

Workflow 01.01. Uses notion, executeWorkflowTrigger, httpRequest. Event-driven trigger; 60 nodes.

Notion, Execute Workflow Trigger, HTTP Request
Data & Sheets

Lmchatopenai Workflow. Uses noOp, stickyNote, executeWorkflowTrigger, airtable. Event-driven trigger; 41 nodes.

Execute Workflow Trigger, Airtable, HTTP Request
Data & Sheets

This n8n workflow retrieves an Airtable record along with its related child records in a hierarchical structure. It can fetch up to 3 levels of linked records and assembles them into a comprehensive J

Execute Workflow Trigger, Airtable, HTTP Request
Data & Sheets

Automate sales call analysis and store structured insights in Notion with AI-powered intelligence.

Execute Workflow Trigger, Notion, HTTP Request