← All N8N workflows
Automation & utilitiesCodeFilterGoogle DriveGoogle Drive TriggerIf

Discard found Google Apps documents

Configured with Filter, Google Drive, Google Drive Trigger, Switch. Review the connections and setup before adapting this template.

Workflow preview
TransformConfigEdit FieldsTransformEdit FieldsEdit FieldsRoutingFilterFilterCodeDeduplicate Keep FirstCodeCodeDeduplicate Keep LastCodeFiles / mediaSend Duplicates toTrashGoogle DriveRoutingNo Operation, donothingNo OpRoutingIs FlaggedIfTriggerGoogle Drive TriggerGoogle Drive TriggerRoutingDrop Google Apps filesFilterFiles / mediaWorking FolderGoogle DriveFiles / mediaGoogle DriveGoogle DriveRoutingKeep First/LastSwitchRoutingTrash/Flag DuplicatesSwitch

Node categories in this workflow

  • Transform
  • Routing
  • Code
  • Files / media
  • Trigger

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
ConfigTransformEdit FieldsSee node parameters
Edit FieldsTransformEdit FieldsSee node parameters
FilterRoutingFilterSee node parameters
Deduplicate Keep FirstCodeCodeSee node parameters
Deduplicate Keep LastCodeCodeSee node parameters
Send Duplicates to TrashFiles / mediaGoogle DrivedeleteFile
No Operation, do nothingRoutingNo OpSee node parameters
Is FlaggedRoutingIfSee node parameters
Google Drive TriggerTriggerGoogle Drive TriggerSee node parameters
Drop Google Apps filesRoutingFilterSee node parameters
Working FolderFiles / mediaGoogle DrivefileFolder
Google DriveFiles / mediaGoogle Driveupdate
Keep First/LastRoutingSwitchSee node parameters
Trash/Flag DuplicatesRoutingSwitchSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • googleDriveOAuth2Api

Workflow notes

2. Configuration

2. Configuration

Choose the keep and action behavior of the workflow

  1. The keep parameter let's you decide whether to keep the first or last received file when duplicates are detected. (possible values: first, last. Default: last)
  2. The action parameter let's you decide what to do with the detected duplicates. Send them to the trash or flag them by renaming them with prefix DUPLICATE- (possible values: trash, flag. Default: flag) flag already prexied by DUPLICATE- are not flagged again.

The parameters owner and folder are taken from the trigger and will probably never need to be changed:

  • The folder points to the folder to work with. By default it is taken from the trigger.
  • The owner parameter needs to match the owner of the files. The workflow only works with files owned by this user. It is specified with the user email and is taken from the first file owner of the trigger.
Working Folder

Working Folder

The "Working Folder" node let's you choose Files to deduplicate.

This workflow includes a filter to work on just 1 folder at depth level 1. It doesn't work with files in nested folders

You can remove the Folder filter to work on the entire drive instead or add different filters.

Discard found Google Apps documents

Discard found Google Apps documents

Docs, Sheets, Forms, Slides, Drawins etc. are discarded because they are not actual binary files and their content can't be directly checked.

1. Trigger Settings and Working Folder

1. Trigger Settings and Working Folder

When using Google Drive Trigger configure the Poll times and the Folder to work with.

By Default the trigger is configured to check for file uploads every 15 minutes.

When configured with a specific folder in the drive the workflow works only with files directly in the folder (It will not check/modify files in sub-folders).

When configured with the root (/) folder of the drive it will check all files in all folders and sub-folders so USE THIS WITH CAUTION since it might lead to trashing/renaming of important files.

In Google Drive Trashed files are kept for 30 days before being permanently deleted.

In Google Drive Trashed files are kept for 30 days before being permanently deleted.

They can be reviewed and restored during that 30 day interval.

Discard found Google Apps documents

Discard found Google Apps documents

Purpose and structure

This folder contains the Discard found Google Apps documents workflow. Its executable nodes use code, filter, googleDrive, googleDriveTrigger, if, noOp, set, switch. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Google Drive Trigger

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Code/0848_Code_Filter_Update_Triggered.json MIT; preserve source notices.

Canvas section labels

These name areas of the original canvas; they do not include explanatory instructions.

  • Files that already start with *DUPLICATE-* are not flagged again.

More in Automation & utilities