效率
Flag Duplicate Files in Google Drive
Watch a Google Drive folder for new files and flag or trash byte-identical copies owned by the same person.
下載工作流程


Watch a Google Drive folder for new files and flag or trash byte-identical copies owned by the same person.
Setup
- Set the same specific My Drive folder ID in Watch one Drive folder and Set folder and duplicate policy. Select the same Google Drive connection for the trigger, List the folder page, and Apply the Drive change. Enable Provider API access on the two API nodes. Authorize Drive write access for existing files and use an account that can rename or trash the affected files. Google Drive permissions
- Keep the default
lastto retain the newest copy by creation time. Setfirstto retain the oldest. In the defaultflagmode, other copies are renamed with the prefixDUPLICATE-. Settrashexplicitly to move those copies to Drive Trash instead. Start with flagging in a test folder and confirm which copies the policy retains before enabling trash. - Publish and enable the workflow.
Behavior
Every 15 minutes, the workflow checks for newly created files directly in the chosen folder. A new file activates a scan for its owner, including earlier files of that owner in the same folder. The workflow identifies copies by Drive’s MD5 checksum. When creation times tie, the lowest file ID breaks the tie consistently across scans. Files without a checksum and Google-native files, including Docs, Sheets and shortcuts, are excluded. Drive file metadata Subfolders and Shared Drives are outside the scope.
Flag mode leaves already-prefixed names alone. Trash mode includes flagged copies and changes only the Drive Trash status. An incomplete folder listing stops the run before changes. Use a folder with at most 20 pages of visible metadata that fit the workflow’s runtime limits. If Drive does not confirm a change, inspect the folder and Trash before repeating the operation. Changes are separate requests and earlier writes may have completed. Avoid editing or moving the same files while a scan is running.
In n8n
Set the folder ID, keep policy and mode in Set folder and duplicate policy. Select the same Google Drive OAuth2 credential in List the folder page and Apply the Drive change, then publish the workflow. The first scheduled run establishes the creation-time baseline without modifying files. New scheduled runs page through the folder with Google Drive’s API and use the same owner and checksum rules. Avoid concurrent runs of this workflow. An unsuccessful poll leaves its time window open, so a later poll reads the actual folder again before planning changes. A processed rename prefix or completed move to Trash is skipped on that reread.
Inspiration & credits
Changes to the source
Read the full folder listing before choosing duplicates and use file IDs to break creation-time ties. Use Drive’s explicit Trash update in trash mode. The n8n schedule uses a fixed creation-time window so its Drive cursor can cover a paginated listing.
Adapted from Google Drive duplicate files in Zie619/n8n-workflows. Attribution: Zie619 / n8n-workflows.
The collection’s MIT notice is pinned at a later revision. This is the collection notice at that revision; it does not establish a separate original template author’s license. Our changes are listed above; see repository licensing.
MIT License
Copyright (c) 2025 Zie619
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.