Automatic alerts when clients upload documents
Most bookkeeping delays don't come from the accounting itself. They come from waiting, checking and chasing: "Has the client sent the bank statements yet?" This article walks through one real automation we built for a client engagement, the full code behind it, and how you can set up the same thing in about half an hour. Client names, email addresses and folder details have been removed.
The problem
One of our clients shares their paperwork with us through a Google Drive folder: receipts, statements, invoices and other documents, organized into subfolders. New files arrive whenever the client gets around to scanning or uploading them.
Google Drive doesn't tell you when someone adds a file to a shared folder. So to know what was new, someone on our team had to open the folder, click into every subfolder and compare dates, again and again. It was slow, easy to forget, and when a statement sat unnoticed for a week, the month-end close waited with it.
The automation
We wrote a short Python script that uses Google's free Drive and Gmail APIs. Every hour it:
- Looks through the client's folder and every subfolder inside it.
- Finds files that were added or changed since the last check.
- If there are any, sends us one email listing each file, which subfolder it's in, when it changed, and a link that opens it.
- Remembers the time of this check, so the next email only shows what's new.
If nothing changed, it stays quiet. The email looks like this (sample file names):
These files in Client documents were added or changed since 11/14/2026, 9:00:00 AM:
- Bank statements/October 2026.pdf – modified 11/14/2026, 4:12:09 PM
- Receipts/Office supplies 11-12.jpg – modified 11/14/2026, 6:40:31 PM
- Tax forms/1099-NEC.pdf – modified 11/15/2026, 8:05:47 AM
The result
- Hours saved. No one opens the folder "just to check" any more. The time we used to spend clicking through subfolders every week now goes to the actual bookkeeping.
- Faster turnaround. Documents get picked up the same day they arrive, instead of whenever someone next remembers to look.
- Nothing slips through. A file dropped into a deep subfolder shows up in the email just like one at the top.
- No extra cost. Google's Drive and Gmail APIs are free at this volume, and the script runs on a computer we already have.
Build it yourself
You need Python 3.9 or later, a Google account that can open the shared folder, and a computer that's on during the working day (or a small always-on server).
1. Let the script use Google Drive and Gmail
- Go to the Google Cloud console, sign in with the Google account that can see the client's folder, and create a new project (for example, "Upload alerts").
- Under APIs & Services → Library, turn on the Google Drive API and the Gmail API.
- Under Google Auth Platform (the OAuth consent screen), enter an app name and your email. Choose Internal if you use Google Workspace; otherwise choose External and add yourself as a test user.
- Under Clients (or Credentials), create an OAuth client ID of type Desktop app, download its JSON file and rename it
credentials.json.
2. Add the script
- Make a folder for the project, for example
upload-alerts, and putcredentials.jsonin it. - Save the script below in the same folder as
drive_upload_alerts.py. -
Change the three settings at the top:
FOLDER_IDis the long code at the end of the folder's web address (drive.google.com/drive/folders/this-part),NOTIFY_EMAILis where the alerts go, andFOLDER_LABELis the name you want to see in the email.
"""Email an alert when files are added or changed in a Google Drive folder."""
import base64
import html
from datetime import datetime, timezone
from email.message import EmailMessage
from pathlib import Path
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
FOLDER_ID = "PASTE_THE_FOLDER_ID_HERE"
NOTIFY_EMAIL = "you@yourfirm.com"
FOLDER_LABEL = "Client documents"
SCOPES = [
"https://www.googleapis.com/auth/drive.metadata.readonly",
"https://www.googleapis.com/auth/gmail.send",
]
HERE = Path(__file__).resolve().parent
CREDENTIALS_FILE = HERE / "credentials.json" # downloaded from Google Cloud
TOKEN_FILE = HERE / "token.json" # created on the first run
STATE_FILE = HERE / "last_check.txt" # time of the last check
FOLDER_TYPE = "application/vnd.google-apps.folder"
def check_folder_changes():
creds = get_credentials()
drive = build("drive", "v3", credentials=creds)
gmail = build("gmail", "v1", credentials=creds)
now = datetime.now(timezone.utc)
if STATE_FILE.exists():
last_check = datetime.fromisoformat(STATE_FILE.read_text().strip())
else:
last_check = now # first run: just record the starting time
changes = []
scan_folder(drive, FOLDER_ID, "", last_check, changes)
if changes:
folder_url = "https://drive.google.com/drive/folders/" + FOLDER_ID
total = len(changes)
since = format_time(last_check)
# HTML version (clickable links)
body_html = (
f'<p>These files in <a href="{folder_url}">{html.escape(FOLDER_LABEL)}</a>'
f" were added or changed since {since}:</p><ul>"
)
for c in changes:
body_html += (
f'<li><a href="{html.escape(c["url"])}">{html.escape(c["path"] + c["name"])}</a>'
f' – modified {format_time(c["updated"])}</li>'
)
body_html += "</ul>"
# Plain-text fallback
text = f'These files in "{FOLDER_LABEL}" were added or changed since {since}:\n\n'
for c in changes:
text += f'• {c["path"]}{c["name"]} ({format_time(c["updated"])})\n {c["url"]}\n'
text += f"\nFolder: {folder_url}"
message = EmailMessage()
message["To"] = NOTIFY_EMAIL
message["Subject"] = f"Drive folder update: {total} file{'' if total == 1 else 's'}"
message.set_content(text)
message.add_alternative(body_html, subtype="html")
raw = base64.urlsafe_b64encode(message.as_bytes()).decode()
gmail.users().messages().send(userId="me", body={"raw": raw}).execute()
STATE_FILE.write_text(now.isoformat())
# Look through a folder and all of its subfolders for recently changed files
def scan_folder(drive, folder_id, path, since, changes):
page_token = None
while True:
response = drive.files().list(
q=f"'{folder_id}' in parents and trashed = false",
fields="nextPageToken, files(id, name, mimeType, modifiedTime, webViewLink)",
pageSize=1000,
pageToken=page_token,
supportsAllDrives=True,
includeItemsFromAllDrives=True,
).execute()
for f in response.get("files", []):
if f["mimeType"] == FOLDER_TYPE:
scan_folder(drive, f["id"], path + f["name"] + "/", since, changes)
continue
updated = datetime.fromisoformat(f["modifiedTime"].replace("Z", "+00:00"))
if updated > since:
changes.append({"name": f["name"], "path": path,
"url": f["webViewLink"], "updated": updated})
page_token = response.get("nextPageToken")
if not page_token:
break
# Sign in with Google the first time, then reuse the saved token
def get_credentials():
creds = None
if TOKEN_FILE.exists():
creds = Credentials.from_authorized_user_file(str(TOKEN_FILE), SCOPES)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(str(CREDENTIALS_FILE), SCOPES)
creds = flow.run_local_server(port=0)
TOKEN_FILE.write_text(creds.to_json())
return creds
# Show times in your computer's time zone, e.g. 11/14/2026, 4:12:09 PM
def format_time(moment):
local = moment.astimezone()
return f"{local.month}/{local.day}/{local.year}, " + local.strftime("%I:%M:%S %p").lstrip("0")
if __name__ == "__main__":
check_folder_changes()
Then install Google's Python libraries in the project folder:
cd upload-alerts
python3 -m venv .venv
.venv/bin/pip install google-api-python-client google-auth-oauthlib
On Windows, use py -m venv .venv and .venv\Scripts\pip instead.
3. Run it once and allow access
- In the project folder, run
.venv/bin/python drive_upload_alerts.py. - A browser window asks you to allow the script to see your Drive file details and send email as you. Because this is your own app, Google may say it hasn't verified it; click Advanced and continue. Review and allow it.
- The script saves your sign-in to
token.jsonso it won't ask again. The first run just records the starting time, so no email is sent yet.
4. Make it run every hour
On a Mac or Linux, run crontab -e and add this line, using the full path to your project folder:
0 * * * * cd /full/path/to/upload-alerts && .venv/bin/python drive_upload_alerts.py
On a Mac, keep the project folder outside Desktop, Documents and Downloads, which macOS doesn't let scheduled jobs
open. On Windows, use Task Scheduler to run .venv\Scripts\python.exe drive_upload_alerts.py
every hour, with the project folder as the Start in folder.
To test it, upload any file to the folder, then run the script again by hand. You should get the email within a minute.
Good to know
- Moved files may not show up. The script looks at each file's "last modified" date. A file that's moved into the folder from elsewhere in Drive keeps its old date, so it won't be listed. New uploads and edited files are always caught.
- Your computer needs to be on. If it's asleep, nothing is lost: the next run lists everything changed since the last check. For alerts around the clock, run the script on a small always-on server.
- Sign-ins can expire after 7 days. If you chose External and left the app in testing, Google ends the saved sign-in after a week and the script stops with an error. Set the app's publishing status to In production (fine for an app only you use), then delete
token.jsonand run the script by hand once. - Email limits. Gmail limits how many emails an account can send per day. One email an hour fits easily.
- One folder per script. For several clients, copy the project folder once per client folder with its own settings, or ask us about a version that watches a list of folders and sends one combined email.
- Keep it private.
credentials.jsonandtoken.jsonlet whoever has them see your Drive file details and send email as you. Keep them on your computer and never share or upload them. The script only reads file names and dates, not what's inside the files, and only sees what your account can see.
Other workflows to automate the same way
The pattern, "check something on a schedule and tell me only when it changes", fits a lot of everyday accounting work:
- Remind a client automatically when an expected document, like a monthly bank statement, hasn't arrived by a set date.
- Rename and file new uploads into the right month's folder.
- Log every new file into a Google Sheet checklist for the month-end close.
- Combine it with an AI agent connected to QuickBooks Online, so new receipts get matched to transactions. See our QBO MCP Automation Access guide.
Want workflows like this for your business?
We look at where your team spends time checking, chasing and re-typing, and automate it.
Book a free consultationGoogle Drive, Gmail and Google Cloud are trademarks of Google LLC. Fidaro is not affiliated with or endorsed by Google.