{"updatedAt":"2026-01-12T19:26:37.000Z","createdAt":"2026-01-12T19:22:44.348Z","id":"Qc8fKq9he8A4BatR_avr5","name":"text-demo-clean","active":false,"isArchived":true,"nodes":[{"parameters":{"httpMethod":"POST","path":"text-demo","responseMode":"responseNode","options":{}},"type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"id":"4161bdb2-d95a-4a41-a921-4e274752d047","name":"Webhook","webhookId":"1d501700-5598-4e09-9f3b-65fc9dcd14af"},{"parameters":{"respondWith":"allIncomingItems","options":{}},"type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1072,16],"id":"3d9dbde0-ae50-4e24-b038-0eb927621410","name":"Respond to Webhook"},{"parameters":{"jsCode":"const data = $json.body || $json;  // in case webhook wrapped it under \"body\"\n\nconst startISO = data.startISO || data.start || $json.startISO || $json.start;\nconst endISO   = data.endISO   || data.end   || $json.endISO   || $json.end;\n\nreturn {\n  startISO,\n  endISO,\n  startEpoch: startISO ? Math.floor(new Date(startISO).getTime() / 1000) : null,\n  endEpoch: endISO ? Math.floor(new Date(endISO).getTime() / 1000) : null\n};\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[208,0],"id":"edbc2d55-47c9-4f76-90ad-250108455b6f","name":"Code in JavaScript"},{"parameters":{"jsCode":"const raw = $json.stdout || \"\";\nconst root = \"/mnt/data/PublicFiles/data/\";\nconst baseUrl = \"https://min.velvetcld.gleeze.com/data\";\n\n// Keep only the lines that actually contain file paths\nconst lines = raw\n  .split(\"\\n\")\n  .filter(line => line.includes(root));\n\n// Turn each line into a JSON item\nconst items = lines.map(line => {\n  // line = \"2025-11-06T10:31:13 /mnt/data/PublicFiles/data/20251106_130340.jpg\"\n  const firstSpace = line.indexOf(\" \");\n  const path = line.slice(firstSpace + 1).trim();       // \"/mnt/data/.../20251106_130340.jpg\"\n  const rel = path.replace(root, \"\");                  // \"20251106_130340.jpg\" (or subdir/file.ext)\n  const name = rel.split(\"/\").pop();                   // just the file name\n\n  // Build public URL for the thumbnail\n  const encodedRel = rel\n    .split(\"/\")\n    .map(encodeURIComponent)\n    .join(\"/\");\n  const url = `${baseUrl}/${encodedRel}`;\n\n  return {\n    name,   // just the filename (what you asked to see)\n    url     // public URL you can use as <img src=\"...\">\n  };\n});\n\nreturn items;\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[624,16],"id":"3c540d88-ab85-426e-b1dd-bbd29892996c","name":"Parse Files"},{"parameters":{"jsCode":"// Collect all file items from \"Parse Files\"\nconst files = $items(\"Parse Files\").map(item => item.json);\n\n// Return a SINGLE item that wraps them\nreturn [\n  {\n    files\n  }\n];\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[832,16],"id":"173a52cb-3b43-41ec-97db-982975b52be6","name":"Wrap For Response"},{"parameters":{"jsCode":"const fs = require('fs');\nconst path = require('path');\n\nconst rootDir = '/mnt/data/PublicFiles/data';\n\n// Inputs produced by \"Code in JavaScript\"\nconst startEpoch = Number($json.startEpoch);\nconst endEpoch = Number($json.endEpoch);\n\nif (!Number.isFinite(startEpoch) || !Number.isFinite(endEpoch)) {\n  throw new Error('Missing/invalid startEpoch or endEpoch. Send startISO/endISO (or start/end) to the webhook.');\n}\n\nconst entries = fs.readdirSync(rootDir, { withFileTypes: true });\n\nconst results = [];\n\nfor (const entry of entries) {\n  if (!entry.isFile()) continue;\n\n  const fullPath = path.join(rootDir, entry.name);\n\n  let st;\n  try {\n    st = fs.statSync(fullPath);\n  } catch (e) {\n    continue; // skip unreadable files\n  }\n\n  const mtimeEpoch = Math.floor(st.mtimeMs / 1000);\n\n  if (mtimeEpoch >= startEpoch && mtimeEpoch <= endEpoch) {\n    // Match the old Execute Command output style so your \"Parse Files\" node keeps working\n    const iso = new Date(mtimeEpoch * 1000).toISOString().slice(0, 19); // YYYY-MM-DDTHH:MM:SS\n    results.push({ json: { stdoutLine: `${iso} ${fullPath}` } });\n  }\n}\n\n// To preserve your existing \"Parse Files\" logic (which reads $json.stdout),\n// we output ONE item with stdout as multi-line text, like Execute Command did.\nconst stdout = results.map(r => r.json.stdoutLine).join('\\n');\nreturn [{ json: { stdout } }];\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[416,0],"id":"e1b02276-82f5-45b0-890f-163a114a8550","name":"List Files (mtime filter)"}],"connections":{"Webhook":{"main":[[{"node":"Code in JavaScript","type":"main","index":0}]]},"Code in JavaScript":{"main":[[{"node":"List Files (mtime filter)","type":"main","index":0}]]},"Parse Files":{"main":[[{"node":"Wrap For Response","type":"main","index":0}]]},"Wrap For Response":{"main":[[{"node":"Respond to Webhook","type":"main","index":0}]]},"List Files (mtime filter)":{"main":[[{"node":"Parse Files","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","availableInMCP":false},"staticData":null,"meta":null,"pinData":{},"versionId":"01203261-cee1-4fb3-984f-f9da986bb057","activeVersionId":null,"triggerCount":0,"shared":[{"updatedAt":"2026-01-12T19:22:44.350Z","createdAt":"2026-01-12T19:22:44.350Z","role":"workflow:owner","workflowId":"Qc8fKq9he8A4BatR_avr5","projectId":"lh2csO3ZG7MzpN8o"}],"activeVersion":null,"tags":[]}