πŸ“ File Google Drive inbox documents into dated folders with a Google Sheets audit log

⚑ 12 views Β· πŸ“ File Management

Description

Quick overview

This workflow monitors a Google Drive inbox folder for new files, classifies them by filename regex rules, files them into a Year/Month/Type folder structure in Google Drive, and logs each success or failure to a Google Sheets audit log.

How it works

  1. Triggers every minute when a new file is created in a selected Google Drive folder.
  2. Evaluates the filename against configurable regular-expression rules to assign a document type, derive the year/month from the file’s created time, and build a destination path.
  3. Uses the planned destination root to find or create the required year folder, then the month folder, then the type folder in Google Drive.
  4. Moves the file into the final type folder.
  5. Appends a β€œFiled” audit row to Google Sheets with timestamp, original filename, matched rule, destination path, and file ID.
  6. If any step errors, appends a β€œFailed” audit row to Google Sheets with error details so the run continues.

Setup

  1. Add Google Drive OAuth2 credentials, select the inbox folder to watch, and ensure the archive root is a different Google Drive folder to avoid reprocessing filed files.
  2. In the rules script, paste your archive root folder ID and adjust the filename regex rules and type folder names as needed.
  3. Add Google Sheets OAuth2 credentials and select the target spreadsheet and sheet tab for both the success and failure audit logs.
  4. Create the audit sheet headers (Timestamp, Original Filename, Matched Rule, Type, Destination Path, File ID, Status, Notes) so appended rows map cleanly.

Requirements

Customization

πŸ”— Nodes Used

Google Sheets, Google Drive, Google Drive Trigger

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup