Automate Google Drive file management using this powerful n8n workflow. Detect, flag, or trash duplicate files based on MD5 checksums and creation time.
Download this n8n workflow template and start using it instantly.
Users looking to maintain a clean and optimized Google Drive storage.
System administrators needing a reliable duplicate file cleanup solution.
Developers seeking robust file operation n8n templates.
Anyone familiar with creating custom logic using an n8n node.
Managing large volumes of files often results in storage being wasted by exact duplicates. This robust n8n workflow solves this problem by using file metadata, specifically the MD5 checksum, to guarantee accurate identification of identical files. The automation starts with an n8n trigger watching a specified folder. Users can configure the desired behavior: choosing to keep the first or last version of the file, and deciding whether to permanently trash the duplicates or merely flag them by prepending "DUPLICATE-" to the filename. This sophisticated use of the n8n node ecosystem allows for highly customized and preventative maintenance of cloud storage, providing a necessary solution missing from native Google Drive features. This n8n workflow is a perfect example of advanced file management.
Config) establishes essential configuration parameters: keep (which file version to keep, default last) and action (what to do with the duplicate, default flag).Working Folder) to pull all relevant files from the specified folder. It then uses a Filter n8n node (Drop Google Apps files) to discard proprietary Google files (Docs, Sheets) as they lack the necessary md5Checksum used for accurate duplicate checking.Keep First/Last) routes the items based on the configured keep parameter. Custom Code n8n node logic is then applied to iterate through the file metadata, sorting them by creation time and marking true duplicates based on matching md5Checksum values. The unwanted version is marked as isDuplicate = true.Trash/Flag Duplicates) determines the execution path based on the user's action variable.action is trash, the duplicate file is sent to the Google Drive trash using another Google Drive n8n node.action is flag, an If n8n node checks if the file is already prefixed with "DUPLICATE-". If not, a Google Drive n8n node renames the file; otherwise, a NoOp n8n node ensures no redundant action occurs. This prevents re-flagging already processed items in this n8n workflow.Google Drive Trigger, Working Folder, and all subsequent Google Drive n8n node instances are connected to your authenticated Google Drive account.Google Drive Trigger n8n node, define the specific folder ID you wish to monitor for new file creations. Ensure the polling interval is set appropriately.Config Set n8n node and adjust the core variables:keep: Set to first or last (determines which creation time version is retained).action: Set to trash (sends the duplicate to trash) or flag (renames it). Google Drive Trigger: The starting n8n trigger. Configured to monitor a specified folder for newly created files, initiating the automation. Key setting is the Folder To Watch.
Config (Set n8n node): Defines crucial parameters (keep, action) that dictate how the rest of the n8n workflow manages the duplicates.
Working Folder (Google Drive n8n node): Retrieves all necessary file metadata (ID, name, md5Checksum, createdTime) from the target folder, filtered by file owner.
Drop Google Apps files (Filter n8n node): A critical filter that excludes files that do not contain a comparable md5Checksum (e.g., Google Docs, Sheets).
Deduplicate Keep Last / Keep First (Code n8n nodes): These Code n8n node blocks implement the core logic. They sort the files by creation date and use custom JavaScript to compare md5Checksums, marking redundant files with the isDuplicate flag.
Trash/Flag Duplicates (Switch n8n node): Directs the flow based on the cleanup policy set in the Config n8n node.
Send Duplicates to Trash (Google Drive n8n node): Executes the deletion, moving the identified duplicate file to the Google Drive trash bin.
Google Drive (Rename) (Google Drive n8n node): If flagging is chosen, this n8n node updates the file name by prepending "DUPLICATE-", offering a non-destructive cleanup option.
Enable AI agents (like Claude or ChatGPT) to read, write, and format Google Docs programmatically using this powerful n8n workflow and MCP server. Leverage the n8n trigger for advanced file operations.

Sync Google Calendar attendees and event RSVP statuses (accepted, declined, canceled) instantly to KlickTipp using this robust n8n workflow. Manage your CRM effortlessly.

Deploy this sophisticated n8n workflow to automate Google Calendar reminders. Uses the n8n trigger (Schedule) and GPT-4o-mini to create friendly, personalized Telegram alerts 1 hour before events.

Automate file retrieval from deeply nested Google Drive folders using this robust n8n workflow. Efficiently list all file IDs from a complex directory structure.

Automate document synchronization from Google Drive to a Supabase vector database using n8n. This powerful n8n workflow features custom chunking, OpenAI contextualization, and hybrid RAG search capabilities.

Automate high-quality, SEO-optimized technical blog posts using this robust n8n workflow. Triggers on new Google Sheets submissions, generates content using multiple AI models (Groq, Mistral), optimizes for GEO/SEO, and includes a mandatory human approval gate via a custom n8n form in Gmail.


IT professional and n8n enthusiast







































