{
  "name": "My workflow",
  "nodes": [
    {
      "parameters": {
        "triggerOn": "folder",
        "path": "/home/angel/Downloads/Telegram Desktop/eco-2026/",
        "events": [
          "add",
          "change",
          "addDir"
        ],
        "options": {
          "ignoreInitial": true
        }
      },
      "id": "ff264170-71ed-4e0f-a2ee-73b2396270c0",
      "name": "Watch Eco Folder",
      "type": "n8n-nodes-base.localFileTrigger",
      "typeVersion": 1,
      "position": [
        -128,
        -144
      ]
    },
    {
      "parameters": {
        "jsCode": "// Rename file with proper convention\nconst path = require('path');\nconst fs = require('fs');\n\nconst filePath = $input.item.json.path;\nconst fileName = path.basename(filePath);\nconst dirName = path.dirname(filePath);\nconst ext = path.extname(fileName).toLowerCase();\n\n// Get current timestamp\nconst now = new Date();\nconst timestamp = now.toISOString().slice(0,19).replace(/[-:T]/g, '').replace(/(.{8})(.{6})/, '$1_$2');\n\n// Determine type based on extension\nlet fileType = 'photo';\nif (['.mp4', '.mov', '.avi', '.webm'].includes(ext)) fileType = 'video';\nif (['.ogg', '.mp3', '.wav', '.m4a'].includes(ext)) fileType = 'audio';\n\n// New filename: YYYYMMDD_HHMMSS_Sicily_type.ext\nconst newFileName = `${timestamp}_Sicily_${fileType}${ext}`;\nconst newPath = path.join(dirName, newFileName);\n\n// Rename the file\nif (filePath !== newPath && fs.existsSync(filePath)) {\n  fs.renameSync(filePath, newPath);\n}\n\nreturn {\n  originalPath: filePath,\n  newPath: newPath,\n  fileName: newFileName,\n  fileType: fileType,\n  timestamp: now.toISOString(),\n  size: fs.statSync(newPath).size\n};"
      },
      "id": "cadc7731-3cde-42b1-aee1-4ff74d28260e",
      "name": "Rename File",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        96,
        -144
      ]
    },
    {
      "parameters": {
        "fileSelector": "/home/angel/Downloads/Telegram Desktop/eco-2026/*.jpeg"
      },
      "id": "1599a0e5-dace-410c-846a-6b122cc7fcf7",
      "name": "Read File",
      "type": "n8n-nodes-base.readBinaryFiles",
      "typeVersion": 1,
      "position": [
        320,
        -144
      ]
    },
    {
      "parameters": {
        "jsCode": "// Log to manifest\nconst fs = require('fs');\nconst manifestPath = '/home/angel/Downloads/Telegram Desktop/eco-2026/manifest.json';\n\nlet manifest = [];\nif (fs.existsSync(manifestPath)) {\n  manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\n}\n\nconst entry = {\n  id: manifest.length + 1,\n  originalFile: $('Rename File').item.json.originalPath,\n  newFile: $('Rename File').item.json.newPath,\n  fileName: $('Rename File').item.json.fileName,\n  fileType: $('Rename File').item.json.fileType,\n  size: $('Rename File').item.json.size,\n  uploadedAt: new Date().toISOString(),\n  googlePhotosId: $json.id || 'pending',\n  status: 'uploaded'\n};\n\nmanifest.push(entry);\nfs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));\n\nreturn entry;"
      },
      "id": "86642254-3499-4ae1-b4f4-8eae86e3e0c2",
      "name": "Log to Manifest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        544,
        -144
      ]
    },
    {
      "parameters": {
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        768,
        -144
      ],
      "id": "ef6a5f4f-0688-422f-9843-2da249bc1b07",
      "name": "Upload file",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Watch Eco Folder": {
      "main": [
        [
          {
            "node": "Rename File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rename File": {
      "main": [
        [
          {
            "node": "Read File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Manifest": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read File": {
      "main": [
        [
          {
            "node": "Log to Manifest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "daa70920-7f45-48fe-b2a2-2705598376f3",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "nZdMde8WUwiNZm3v",
  "tags": []
}