获取Google Drive文件夹内所有文件
中级
这是一个File Management领域的自动化工作流,包含 14 个节点。主要使用 If, Set, Code, GoogleDrive, SplitInBatches 等节点。 支持嵌套文件夹的Google Drive工作流
前置要求
- •Google Drive API 凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "WyWBYMQWkj2qOEYW",
"meta": {
"instanceId": "b50483b2122f6dc268662b45507d575d939570ea8e1e086601ebb3b6273c1cfd",
"templateCredsSetupCompleted": true
},
"name": "获取GoogleDrive文件夹内的所有文件",
"tags": [],
"nodes": [
{
"id": "7ad58632-aaae-49d1-8a4d-192696ea5fbe",
"name": "如果父文件夹没有文件夹",
"type": "n8n-nodes-base.if",
"position": [
720,
224
],
"parameters": {},
"typeVersion": 2.2
},
{
"id": "e295dc16-bee6-4c2d-a1c4-275c093ee98a",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-224,
-304
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "306a72d8-17cb-491e-ab71-563d67033dc4",
"name": "如果父文件夹有嵌套文件夹或没有",
"type": "n8n-nodes-base.if",
"position": [
464,
96
],
"parameters": {},
"typeVersion": 2.2
},
{
"id": "c7066d3c-db7e-4d10-8ea7-844f4a7f92b5",
"name": "开始执行",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-16,
96
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "37ad0017-a81e-4142-a699-5979917d3e3e",
"name": "获取所有文件夹ID",
"type": "n8n-nodes-base.code",
"position": [
928,
-32
],
"parameters": {},
"typeVersion": 2
},
{
"id": "f395e3b0-4010-4ce6-b9e4-d40c38eaf6e2",
"name": "返回父文件夹ID",
"type": "n8n-nodes-base.set",
"position": [
928,
144
],
"parameters": {},
"typeVersion": 3.4
},
{
"id": "69349d16-147a-4a53-921f-2afbce976421",
"name": "将父文件夹ID返回到子工作流",
"type": "n8n-nodes-base.set",
"position": [
928,
304
],
"parameters": {},
"typeVersion": 3.4
},
{
"id": "cc185a48-6793-4dea-ab4b-1a4227391552",
"name": "开始子执行",
"type": "n8n-nodes-base.executeWorkflow",
"position": [
720,
-32
],
"parameters": {},
"typeVersion": 1.2
},
{
"id": "97895244-0065-4aa8-b200-87782f6bcf8c",
"name": "从文件夹ID获取子文件夹",
"type": "n8n-nodes-base.googleDrive",
"position": [
240,
96
],
"parameters": {},
"executeOnce": true,
"typeVersion": 3,
"alwaysOutputData": true
},
{
"id": "9df3e103-c7a7-41dc-a5e0-0b77b4959a93",
"name": "循环遍历文件夹ID",
"type": "n8n-nodes-base.splitInBatches",
"position": [
1600,
-32
],
"parameters": {},
"typeVersion": 3
},
{
"id": "15f2bc5a-0c2f-45f8-b7dc-b4775641f6c1",
"name": "获取文件夹内的所有文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
1856,
192
],
"parameters": {},
"typeVersion": 3
},
{
"id": "1fe7e380-e5a2-422d-a91f-3c9382fadedf",
"name": "返回所有文件ID",
"type": "n8n-nodes-base.set",
"position": [
1856,
-48
],
"parameters": {},
"typeVersion": 3.4
},
{
"id": "c9b24b37-9745-4e4d-b9bc-895765c0b210",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-64,
-128
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "fe94e670-7de0-42ce-889b-d755b4edb5bf",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1424,
-128
],
"parameters": {
"content": ""
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "49da4933-34df-466f-912e-7bd8f02d0b20",
"connections": {
"Start Execution": {
"main": [
[
{
"node": "Get children folders from folder id",
"type": "main",
"index": 0
}
]
]
},
"Get all folder ids": {
"main": [
[
{
"node": "Loop Over folder ids",
"type": "main",
"index": 0
}
]
]
},
"Start sub-execution": {
"main": [
[
{
"node": "Get all folder ids",
"type": "main",
"index": 0
}
]
]
},
"Loop Over folder ids": {
"main": [
[
{
"node": "Return all file ids",
"type": "main",
"index": 0
}
],
[
{
"node": "Get all files inside a folder",
"type": "main",
"index": 0
}
]
]
},
"Return parent folder id": {
"main": [
[
{
"node": "Loop Over folder ids",
"type": "main",
"index": 0
}
]
]
},
"Get all files inside a folder": {
"main": [
[
{
"node": "Loop Over folder ids",
"type": "main",
"index": 0
}
]
]
},
"If parent folder has no folder": {
"main": [
[
{
"node": "Return parent folder id",
"type": "main",
"index": 0
}
],
[
{
"node": "Return parent folder id to sub-workflow",
"type": "main",
"index": 0
}
]
]
},
"Get children folders from folder id": {
"main": [
[
{
"node": "If parent folder has nested folders or not",
"type": "main",
"index": 0
}
]
]
},
"Return parent folder id to sub-workflow": {
"main": [
[]
]
},
"If parent folder has nested folders or not": {
"main": [
[
{
"node": "Start sub-execution",
"type": "main",
"index": 0
}
],
[
{
"node": "If parent folder has no folder",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 文件管理
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
在Google Drive文件夹中整理邮件附件
根据发件人邮箱在Google Drive文件夹中整理Gmail附件
If
Set
Code
+10
17 节点Davide
文件管理
API架构提取器
API架构提取器
If
Set
Code
+22
88 节点Polina Medvedieva
工程
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
使用Google Drive、Gmail和Discord警报的自动化工作流备份系统
使用Google Drive、Gmail和Discord警报的自动化工作流备份系统
If
N8n
Set
+11
29 节点HoChien Chang
IT 运维
上下文混合RAG AI文案
Google Drive到Supabase上下文向量数据库同步用于RAG应用
If
Set
Code
+25
76 节点Michael Taleb
AI RAG 检索增强
(Duc)深度研究市场模板
集成PerplexityAI研究和OpenAI内容的多层级WordPress博客生成器
If
Set
Xml
+28
132 节点Daniel Ng
人工智能