Google Drive工作流
高级
这是一个File Management领域的自动化工作流,包含 19 个节点。主要使用 If, Set, Code, Merge, DateTime 等节点。 自动监控和下载Google Drive中变更的文件
前置要求
- •Google Drive API 凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "Zm3vlJ68snvoKOBG",
"meta": {
"instanceId": "2d34387799014884b6bb4a0dc8b683ee92ad2bcf5aadb21177a0062d65f47540"
},
"name": "google drive 工作流",
"tags": [],
"nodes": [
{
"id": "96c1dd68-0754-4142-b4a3-33da8c7ecbb4",
"name": "无操作",
"type": "n8n-nodes-base.noOp",
"position": [
60,
-180
],
"parameters": {},
"typeVersion": 1
},
{
"id": "1311ef97-df8e-413c-b2a4-744f6d52a464",
"name": "合并",
"type": "n8n-nodes-base.merge",
"position": [
280,
-280
],
"parameters": {},
"typeVersion": 2
},
{
"id": "36218a2a-19cb-411b-b16c-abac840c781d",
"name": "创建时间戳文件",
"type": "n8n-nodes-base.code",
"position": [
1160,
-280
],
"parameters": {
"jsCode": "// Get ISO string from DateTime node\nconst dateString = $json['date'] || new Date().toISOString();\n\n// Return in expected format\nreturn [{\n json: {},\n binary: {\n data: {\n data: Buffer.from(dateString).toString('base64'),\n mimeType: 'text/plain'\n }\n }\n}];"
},
"typeVersion": 1
},
{
"id": "edc76c05-1f99-4013-b9fe-b13adcac72af",
"name": "计划触发器1",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-1480,
-280
],
"parameters": {
"rule": {
"interval": [
{
"field": "minutes"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "7127ff0e-88c3-4de3-a20d-9691af5cb97e",
"name": "搜索时间戳文件1",
"type": "n8n-nodes-base.googleDrive",
"onError": "continueRegularOutput",
"position": [
-1260,
-280
],
"parameters": {
"filter": {},
"options": {
"fields": [
"*"
]
},
"resource": "fileFolder",
"returnAll": true,
"queryString": "=name = 'n8n_last_run.txt' and trashed = false",
"searchMethod": "query"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "2ntQDVP0dIsxbgub",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "1bec1940-0532-4329-9661-fb2bccf00ccd",
"name": "下载时间戳文件1",
"type": "n8n-nodes-base.googleDrive",
"position": [
-1040,
-280
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "2ntQDVP0dIsxbgub",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "93a1e5f1-cfcd-409a-861d-ac2fe26e02fa",
"name": "下载新文件2",
"type": "n8n-nodes-base.googleDrive",
"position": [
60,
-380
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "2ntQDVP0dIsxbgub",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "97cadaca-a362-401b-9024-f4c982fbdfce",
"name": "上传新时间戳2",
"type": "n8n-nodes-base.googleDrive",
"position": [
1380,
-280
],
"parameters": {
"name": "n8n_last_run.txt",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1ycXdgyWRiQ_Ce_IgeZN1au6QKQNYOMJn",
"cachedResultUrl": "https://drive.google.com/drive/folders/1ycXdgyWRiQ_Ce_IgeZN1au6QKQNYOMJn",
"cachedResultName": "n8n Workflows"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "2ntQDVP0dIsxbgub",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "1fe60540-aedd-4b20-9ec4-44f63e9c995b",
"name": "条件判断",
"type": "n8n-nodes-base.if",
"position": [
-160,
-280
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9f2f6596-c151-4fa1-aadd-ec26345aba4d",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.id }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "51894b5f-1a9c-416c-b3ee-49bb20c904f1",
"name": "编辑字段",
"type": "n8n-nodes-base.set",
"position": [
500,
-280
],
"parameters": {
"options": {}
},
"executeOnce": true,
"typeVersion": 3.4
},
{
"id": "3d6cbf9c-da08-42d4-a682-bf0c97700754",
"name": "提取时间戳文本1",
"type": "n8n-nodes-base.extractFromFile",
"position": [
-820,
-280
],
"parameters": {
"options": {},
"operation": "text"
},
"typeVersion": 1
},
{
"id": "7004e5b2-1d35-4900-ae9a-90e8d4ce2d49",
"name": "编辑字段2",
"type": "n8n-nodes-base.set",
"position": [
-600,
-280
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "d6a28651-3a08-4a34-a5a7-e53bb335c83b",
"name": "searchFromTimestamp",
"type": "string",
"value": "={{ $json.data || new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString() }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "10fae4c7-57ab-44c4-86d1-34ea5fea1316",
"name": "搜索新文件2",
"type": "n8n-nodes-base.googleDrive",
"position": [
-380,
-280
],
"parameters": {
"filter": {},
"options": {
"fields": [
"*"
]
},
"resource": "fileFolder",
"returnAll": true,
"queryString": "='1ycXdgyWRiQ_Ce_IgeZN1au6QKQNYOMJn' in parents and (createdTime > '{{ $json.searchFromTimestamp }}' OR modifiedTime > '{{ $json.searchFromTimestamp }}') and trashed = false",
"searchMethod": "query"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "2ntQDVP0dIsxbgub",
"name": "Google Drive account"
}
},
"executeOnce": true,
"typeVersion": 3,
"alwaysOutputData": true
},
{
"id": "358f5927-e9ce-4935-b9bb-4f34996cb932",
"name": "获取当前时间1",
"type": "n8n-nodes-base.dateTime",
"position": [
940,
-280
],
"parameters": {
"options": {
"timezone": "UTC",
"includeInputFields": false
}
},
"typeVersion": 2
},
{
"id": "8f058442-c3e4-47f2-8185-388856bb9338",
"name": "删除旧时间戳文件1",
"type": "n8n-nodes-base.googleDrive",
"position": [
720,
-280
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $node[\"Search for Timestamp File1\"].json.id }}"
},
"options": {},
"operation": "deleteFile"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "2ntQDVP0dIsxbgub",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "47c471f5-e804-42f1-a8b5-d35ec2982daa",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1580,
-520
],
"parameters": {
"width": 150,
"height": 180,
"content": "工作流目的"
},
"typeVersion": 1
},
{
"id": "c8aa3c8a-46ab-449a-936c-93955f6f3083",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1280,
-520
],
"parameters": {
"content": "所需设置"
},
"typeVersion": 1
},
{
"id": "a5b5c496-231f-44bc-bfb9-7c96b89067cc",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-860,
-520
],
"parameters": {
"content": "时间戳文件"
},
"typeVersion": 1
},
{
"id": "5c5b741d-2237-4228-afc4-a13eea55faf1",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1240,
-600
],
"parameters": {
"content": "时间戳更新"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "e46a567b-2ca8-474e-a054-433d282bfce9",
"connections": {
"If": {
"main": [
[
{
"node": "Download New Files2",
"type": "main",
"index": 0
}
],
[
{
"node": "No Operation",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Delete Old Timestamp File1",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields2": {
"main": [
[
{
"node": "Search for New Files2",
"type": "main",
"index": 0
}
]
]
},
"No Operation": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Get Current Time1": {
"main": [
[
{
"node": "Create Timestamp File",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger1": {
"main": [
[
{
"node": "Search for Timestamp File1",
"type": "main",
"index": 0
}
]
]
},
"Download New Files2": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Create Timestamp File": {
"main": [
[
{
"node": "Upload New Timestamp2",
"type": "main",
"index": 0
}
]
]
},
"Search for New Files2": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Extract Timestamp Text1": {
"main": [
[
{
"node": "Edit Fields2",
"type": "main",
"index": 0
}
]
]
},
"Download Timestamp File1": {
"main": [
[
{
"node": "Extract Timestamp Text1",
"type": "main",
"index": 0
}
]
]
},
"Delete Old Timestamp File1": {
"main": [
[
{
"node": "Get Current Time1",
"type": "main",
"index": 0
}
]
]
},
"Search for Timestamp File1": {
"main": [
[
{
"node": "Download Timestamp File1",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 文件管理
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
宠物店 4
🐶 宠物店预约 AI 代理
If
Set
Code
+41
187 节点Bruno Dias
人工智能
交付汉堡店MVP
🤖 餐厅与配送自动化的 AI 驱动 WhatsApp 助手
If
Set
Code
+37
152 节点Bruno Dias
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
通过Spook集成将E.ON W1000电能表数据导入Home Assistant
通过Spook集成将E.ON W1000电能表数据导入Home Assistant
If
Set
Code
+13
46 节点András Farkas
发票处理与验证 - n8n 模板
基于Gmail、Drive、表格和OCR AI的发票验证与确认
If
Set
Code
+13
47 节点Dhrumil Patel
财务
✨🩷自动化社交媒体内容发布工厂 + 系统提示组合
基于动态系统提示和GPT-4o的AI驱动多平台社交媒体内容工厂
If
Set
Code
+20
100 节点Amit Mehta
内容创作