自动移动文件
高级
这是一个File Management领域的自动化工作流,包含 19 个节点。主要使用 If、GoogleDrive、ManualTrigger、SplitInBatches 等节点。 Google云端硬盘自动文件整理器:按类型分类PDF、图片和文档
前置要求
- •Google Drive API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "Kg8UgSiA0utYWQ0J",
"meta": {
"instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177",
"templateCredsSetupCompleted": true
},
"name": "自动移动文件",
"tags": [],
"nodes": [
{
"id": "ebf3a973-602f-4a01-8a74-6df55ad6d113",
"name": "如果是图片",
"type": "n8n-nodes-base.if",
"notes": "🖼️ IMAGE FILE DETECTION\n\nChecks if the uploaded file is an image:\n\n• Examines the file's MIME type\n• Looks for 'image/' in the MIME type\n• Supports: JPG, PNG, GIF, WebP, SVG, etc.\n• TRUE path: Routes to 'Move to Images'\n• FALSE path: File continues to next filter\n\nExample MIME types: image/jpeg, image/png",
"position": [
400,
976
],
"parameters": {
"options": {
"ignoreCase": true,
"looseTypeValidation": false
},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": false,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "3e4622cc-91f0-4cbd-bd55-e3ad4e28f32b",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{$binary.data.mimeType}}",
"rightValue": "image/jpeg"
}
]
}
},
"typeVersion": 2,
"alwaysOutputData": true
},
{
"id": "13e7f0a2-8dde-4e42-a94f-1f81353c95e9",
"name": "如果是PDF",
"type": "n8n-nodes-base.if",
"notes": "📄 PDF FILE DETECTION\n\nChecks if the uploaded file is a PDF document:\n\n• Looks for exact MIME type 'application/pdf'\n• Only matches PDF files\n• TRUE path: Routes to 'Move to PDFs'\n• FALSE path: File continues to next filter\n\nThis ensures only genuine PDF files are moved to the PDF folder.",
"position": [
256,
576
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "18052dba-fa6b-4fd4-ac5f-f6abb10575b9",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{$binary.data.mimeType}}",
"rightValue": "application/pdf"
}
]
}
},
"typeVersion": 2
},
{
"id": "e5331e89-34c7-4e63-b542-0d44b7e1aa42",
"name": "移动到图片文件夹",
"type": "n8n-nodes-base.googleDrive",
"notes": "📁 MOVE IMAGE FILES\n\nMoves detected image files to the Images folder:\n\n• Uses the file ID from the trigger\n• Moves file to designated Images folder\n• Maintains file properties and permissions\n• Removes file from upload folder\n\nReplace 'YOUR_FOLDER_ID_IMAGES' with your actual Images folder ID.",
"position": [
672,
1328
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json['id'] }}"
},
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1_ecL9heszdG2vACtpfHsVEe4OAs89DzM",
"cachedResultUrl": "https://drive.google.com/drive/folders/1_ecL9heszdG2vACtpfHsVEe4OAs89DzM",
"cachedResultName": "images_check"
},
"operation": "move"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "gQtjXVGUgZru29qC",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "d456c42b-604e-4a1d-ac7b-cea42c35a004",
"name": "移动到PDF文件夹",
"type": "n8n-nodes-base.googleDrive",
"notes": "📄 MOVE PDF FILES\n\nMoves detected PDF files to the PDFs folder:\n\n• Uses the file ID from the trigger\n• Moves file to designated PDFs folder\n• Maintains file properties and permissions\n• Removes file from upload folder\n\nReplace 'YOUR_FOLDER_ID_PDFS' with your actual PDFs folder ID.",
"position": [
608,
752
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json['id'] }}"
},
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1dHG2GI5WF3bg-Bw9ydD5fC_P5GqvdBFG",
"cachedResultUrl": "https://drive.google.com/drive/folders/1dHG2GI5WF3bg-Bw9ydD5fC_P5GqvdBFG",
"cachedResultName": "pdf_check"
},
"operation": "move"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "gQtjXVGUgZru29qC",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "49fdce70-3f51-4edd-81fd-7c6f655b6c62",
"name": "如果是文档",
"type": "n8n-nodes-base.if",
"notes": "📋 DOCUMENT FILE DETECTION\n\nChecks if the uploaded file is a document:\n\n• Looks for 'application/' OR 'text/' MIME types\n• Catches: Word docs, Excel, PowerPoint, text files\n• Excludes PDFs (handled separately)\n• TRUE path: Routes to 'Move to Documents'\n• FALSE path: File stays in upload folder\n\nExamples: .docx, .xlsx, .pptx, .txt, .rtf",
"position": [
-48,
304
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "5ed7c752-f41d-496d-a003-56c95572b629",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{$binary.data.mimeType}}",
"rightValue": "application/json"
}
]
}
},
"typeVersion": 2
},
{
"id": "6b1feaf3-4e3b-427c-9e82-7e5df72f284c",
"name": "移动到文档文件夹",
"type": "n8n-nodes-base.googleDrive",
"notes": "📋 MOVE DOCUMENT FILES\n\nMoves detected document files to the Documents folder:\n\n• Uses the file ID from the trigger\n• Moves file to designated Documents folder\n• Handles Word, Excel, PowerPoint, text files\n• Maintains file properties and permissions\n\nReplace 'YOUR_FOLDER_ID_DOCUMENTS' with your actual Documents folder ID.",
"position": [
528,
288
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json['id'] }}"
},
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1KUO_jw0WCQR1lDwlkvTk1XP_0PoLb3RR",
"cachedResultUrl": "https://drive.google.com/drive/folders/1KUO_jw0WCQR1lDwlkvTk1XP_0PoLb3RR",
"cachedResultName": "json_check"
},
"operation": "move"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "gQtjXVGUgZru29qC",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "35df71bd-e674-4dc6-bbac-4ca6ae319d04",
"name": "下载文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
-512,
304
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{$json['id']}}"
},
"options": {},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "gQtjXVGUgZru29qC",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "358f6aba-5ac4-48c3-980a-296a75cae6fd",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-496,
912
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "42c75b0e-47eb-442a-a842-e3e2fbe75d71",
"name": "当点击“执行工作流”时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-944,
912
],
"parameters": {},
"typeVersion": 1
},
{
"id": "fb6d583c-79e8-433e-916c-e71da9352e4b",
"name": "搜索文件和文件夹",
"type": "n8n-nodes-base.googleDrive",
"position": [
-720,
912
],
"parameters": {
"filter": {
"folderId": {
"__rl": true,
"mode": "list",
"value": "1CcHp9tPoC-f7-umMjLdUU-Y7GedKLQkx",
"cachedResultUrl": "https://drive.google.com/drive/folders/1CcHp9tPoC-f7-umMjLdUU-Y7GedKLQkx",
"cachedResultName": "Indore"
}
},
"options": {},
"resource": "fileFolder",
"returnAll": true
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "gQtjXVGUgZru29qC",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "c7a7346e-0529-4191-a7cb-c56f02781d2a",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-832,
672
],
"parameters": {
"height": 224,
"content": "搜索文件和文件夹 (Google Drive)"
},
"typeVersion": 1
},
{
"id": "ed19e989-a464-48cd-9b27-43d9850df4de",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-496,
704
],
"parameters": {
"color": 3,
"width": 272,
"height": 192,
"content": "遍历项目(分批处理)"
},
"typeVersion": 1
},
{
"id": "107bb7f1-ff82-4b04-8e4b-9beea97d479a",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-752,
48
],
"parameters": {
"color": 2,
"width": 272,
"height": 224,
"content": "下载文件 (Google Drive)"
},
"typeVersion": 1
},
{
"id": "57ee82da-1948-4185-abf4-dc8bd251c125",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-144,
-16
],
"parameters": {
"color": 4,
"width": 304,
"height": 288,
"content": "如果是文档(条件节点)"
},
"typeVersion": 1
},
{
"id": "775c6f0f-3dbc-4e29-a7a3-97fd13a08afd",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
432,
16
],
"parameters": {
"color": 6,
"height": 240,
"content": "移动到文档 (Google Drive)"
},
"typeVersion": 1
},
{
"id": "e96270c2-507a-4ac7-aa62-0aaf28ed3c2c",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-32,
608
],
"parameters": {
"color": 5,
"height": 304,
"content": "如果是PDF(条件节点)"
},
"typeVersion": 1
},
{
"id": "f92b7dcb-e767-42da-899d-2bff7130b60e",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
512
],
"parameters": {
"color": 3,
"height": 272,
"content": "移动到PDF (Google Drive)"
},
"typeVersion": 1
},
{
"id": "17fd8e38-d636-496f-a1d7-ec413148a2bc",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
1120
],
"parameters": {
"color": 7,
"height": 368,
"content": "如果是图片(条件节点)"
},
"typeVersion": 1
},
{
"id": "8c58f9d7-5c77-4d2a-83f9-061c2ac30810",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
832,
1312
],
"parameters": {
"color": 5,
"height": 272,
"content": "移动到图片 (Google Drive)"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "d08c53f6-2f34-4ffb-acb7-02d2fa36e73b",
"connections": {
"If PDF": {
"main": [
[
{
"node": "Move to PDFs",
"type": "main",
"index": 0
}
],
[
{
"node": "If Image",
"type": "main",
"index": 0
}
]
]
},
"If Image": {
"main": [
[
{
"node": "Move to Images",
"type": "main",
"index": 0
}
],
[]
]
},
"If Document": {
"main": [
[
{
"node": "Move to Documents",
"type": "main",
"index": 0
}
],
[
{
"node": "If PDF",
"type": "main",
"index": 0
}
]
]
},
"Move to PDFs": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Download file": {
"main": [
[
{
"node": "If Document",
"type": "main",
"index": 0
}
]
]
},
"Move to Images": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Download file",
"type": "main",
"index": 0
}
]
]
},
"Move to Documents": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Search files and folders": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Search files and folders",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个高级难度的工作流,适用于File Management等场景。适合高级用户,包含 16+ 个节点的复杂工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
JSON文件夹分离
从Google表格批量下载JSON文件到本地文件夹
Code
Http Request
Google Sheets
+4
16 节点Rahul Joshi
File Management
事件管理工作流
通过Jira、Slack、Google Sheets和Drive自动化事件响应
If
Set
Code
+8
23 节点Rahul Joshi
DevOps
自动化测试运行和状态更新
自动化工作流测试运行器,集成 Google Drive、Sheets 和 ClickUp 结果记录
If
Set
Code
+7
27 节点Rahul Joshi
从Google Drive生成n8n模板描述
使用Azure GPT-4从Google Drive生成模板描述
Code
Gmail
Google Drive
+9
27 节点Rahul Joshi
Content Creation
将服装图片上传到Cloudinary并使用Azure OpenAI (GPT-4o) 记录到工作表
使用GPT-4o、Cloudinary和Google Sheets处理和编目服装图片
Set
Code
Merge
+9
26 节点Rahul Joshi
Content Creation
技能差距 → 培训推荐
为 HR 团队使用 GPT-4o、Google Sheets 和 Gmail 个性化候选人反馈
If
Code
Gmail
+7
27 节点Rahul Joshi
Content Creation
工作流信息
难度等级
高级
节点数量19
分类1
节点类型5
作者
Rahul Joshi
@rahul08Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.
外部链接
在 n8n.io 上查看 →
分享此工作流