8
n8n 中文网amn8n.com

压缩多个文件

初级

这是一个Building Blocks领域的自动化工作流,包含 5 个节点。主要使用 Set, Code, Compression, ExecuteWorkflowTrigger 等节点。 可复用子工作流:动态压缩多个文件

前置要求
  • 无特殊前置要求,导入即可使用
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "r3qHlCVCczqTw3pP",
  "meta": {
    "instanceId": "1bc0f4fa5e7d17ac362404cbb49337e51e5061e019cfa24022a8667c1f1ce287"
  },
  "name": "压缩多个文件",
  "tags": [],
  "nodes": [
    {
      "id": "8de50ed2-b298-4701-8747-f6c7158fa15f",
      "name": "执行工作流触发器",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5e03dfdd-696e-4a04-99e9-4094ae4371ac",
      "name": "压缩",
      "type": "n8n-nodes-base.compression",
      "position": [
        460,
        0
      ],
      "parameters": {
        "fileName": "=data{{$now.format('yyyy-MM-dd-tt')}}.zip",
        "operation": "compress",
        "binaryPropertyName": "={{ $json.binary_keys }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "e25abf55-fb05-47d0-ba65-9b4e2f08d856",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        -100
      ],
      "parameters": {
        "height": 360,
        "content": "## 关于"
      },
      "typeVersion": 1
    },
    {
      "id": "db7b6475-25b5-44de-b37e-70b75c91455e",
      "name": "准备输出",
      "type": "n8n-nodes-base.set",
      "position": [
        680,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b0c3c3db-584a-48c9-b0ca-7f527d35f5a4",
              "name": "fileName",
              "type": "string",
              "value": "={{ $binary.data.fileName.replaceAll(\" \",\"\") }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "6cf6b9ba-e5a3-4d5f-a539-e84d839f7e99",
      "name": "代码魔法",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        0
      ],
      "parameters": {
        "jsCode": "let binaries = {}, binary_keys = [];\n\nfor (const [index, inputItem] of Object.entries($input.all())) {\n  binaries[`data_${index}`] = inputItem.binary.data;\n  binary_keys.push(`data_${index}`);\n}\n\nreturn [{\n    json: {\n        binary_keys: binary_keys.join(',')\n    },\n    binary: binaries\n}];\n"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "16f64706-0a2a-4f9f-a96f-f149a4874ae4",
  "connections": {
    "Code Magic": {
      "main": [
        [
          {
            "node": "Compression",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compression": {
      "main": [
        [
          {
            "node": "Prepare Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Code Magic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

初级 - 构建模块

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
初级
节点数量5
分类1
节点类型5
难度说明

适合 n8n 新手,包含 1-5 个节点的简单工作流

作者

I am an E-commerce entrepreneur specializing in spare parts, with a strong passion for automation and AI. I leverage n8n to build complex workflows, integrating tools like SeaTable, Supabase with various E-com platforms. I'm dedicated to continuously improving workflow processes, particularly in the e-commerce sector.

外部链接
在 n8n.io 查看

分享此工作流