{"updatedAt":"2026-01-12T18:55:25.249Z","createdAt":"2025-11-09T12:01:00.724Z","id":"fvb6Mmn3xY6gIMZO","name":"text-demo","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"text-demo","responseMode":"responseNode","options":{}},"type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"id":"f5f21e08-3dfc-4fc8-ae98-58ca9c4b803d","name":"Webhook","webhookId":"1d501700-5598-4e09-9f3b-65fc9dcd14af"},{"parameters":{"respondWith":"allIncomingItems","options":{}},"type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1072,16],"id":"0df71f18-a83a-4878-b699-d1edaaa09ce5","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":"191001ba-f901-41e5-a9de-09b8edefc019","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":"9071f577-597e-4392-a66e-3f5e0120e9d2","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":"2eb50434-0183-462e-be3f-1a0beb3bb8f7","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":"d2b977ef-67b7-46b9-8b1f-27a691a5ed17","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"},"staticData":null,"meta":{"templateCredsSetupCompleted":true},"pinData":{},"versionId":"789935ce-f2f3-4fc4-9397-7ad9b0f7365b","activeVersionId":"68a1e314-f9bc-4398-a0a4-0097a9f39f2b","triggerCount":1,"shared":[{"updatedAt":"2025-11-09T12:01:00.726Z","createdAt":"2025-11-09T12:01:00.726Z","role":"workflow:owner","workflowId":"fvb6Mmn3xY6gIMZO","projectId":"lh2csO3ZG7MzpN8o"}],"activeVersion":{"updatedAt":"2025-11-27T21:37:34.259Z","createdAt":"2025-11-27T21:37:34.259Z","versionId":"68a1e314-f9bc-4398-a0a4-0097a9f39f2b","workflowId":"fvb6Mmn3xY6gIMZO","nodes":[{"parameters":{"httpMethod":"POST","path":"text-demo","responseMode":"responseNode","options":{}},"type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"id":"f5f21e08-3dfc-4fc8-ae98-58ca9c4b803d","name":"Webhook","webhookId":"1d501700-5598-4e09-9f3b-65fc9dcd14af"},{"parameters":{"respondWith":"allIncomingItems","options":{}},"type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1072,16],"id":"0df71f18-a83a-4878-b699-d1edaaa09ce5","name":"Respond to Webhook"},{"parameters":{"command":"=start_epoch={{ $json.startEpoch }}\nend_epoch={{ $json.endEpoch }}\n\necho \"Start epoch: $start_epoch\"\necho \"End epoch:   $end_epoch\"\necho \"----- Files in range -----\"\n\nfor f in /mnt/data/PublicFiles/data/*; do\n  [ -f \"$f\" ] || continue\n  mtime=$(stat -c %Y \"$f\" 2>/dev/null)\n  if [ \"$mtime\" -ge \"$start_epoch\" ] && [ \"$mtime\" -le \"$end_epoch\" ]; then\n    echo \"$(date -d @\"$mtime\" '+%Y-%m-%dT%H:%M:%S') $f\"\n  fi\ndone\n"},"type":"n8n-nodes-base.executeCommand","typeVersion":1,"position":[416,16],"id":"e1e77571-9541-4220-8283-cff8e5d7edd7","name":"Execute Command"},{"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":"191001ba-f901-41e5-a9de-09b8edefc019","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":"9071f577-597e-4392-a66e-3f5e0120e9d2","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":"2eb50434-0183-462e-be3f-1a0beb3bb8f7","name":"Wrap For Response"}],"connections":{"Webhook":{"main":[[{"node":"Code in JavaScript","type":"main","index":0}]]},"Execute Command":{"main":[[{"node":"Parse Files","type":"main","index":0}]]},"Code in JavaScript":{"main":[[{"node":"Execute Command","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}]]}},"authors":"system migration","name":null,"description":null,"autosaved":false},"tags":[]}