Skip to content

Hourly or daily

Keep your uploads folder sorted

New files get a dated name and move into folders by type, and duplicates are reported to you.

Runs
Hourly or daily
Apps
Google Drive
AI
Not needed
Access
read+write (drive)

Send this to your assistant

Create a ClickRuntime automation: every hour, rename new files in my Inbox folder to YYYY-MM-DD_name, move PDFs, images and docs into matching subfolders, and email me any duplicates by name and size.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

An uploads folder shared by a whole office slowly turns into a dumping ground. Scanned receipts arrive as IMG_4821.jpg, the same contract is saved three times with slightly different names, and PDFs, spreadsheets and photos all sit in one flat list. Finding last quarter's supplier invoice means scrolling through hundreds of files, and storage fills with copies nobody can safely delete.

On the schedule you pick, hourly or daily, ClickRuntime lists the files in the folder and works out a new name and destination for each. Names get the file's date, files are moved into folders by type using Drive's addParents and removeParents, and files with the same md5Checksum are collected into a report so you can decide which copy to remove.

It works best as a shared inbox folder that people use without thinking about naming rules.

What you get out of it

  • Files you can find by date

    A date at the start of each name makes a folder sort chronologically. Looking for something from August takes seconds, and nobody has to open a dozen files called scan1 to find the right one.

  • Fewer wasted gigabytes

    Matching md5Checksum values identify identical content even when the names differ. Removing true copies reclaims space and avoids paying to store the same video or archive several times over, which adds up quickly on shared drives.

  • Staff keep their own habits

    People can keep dropping files in without learning a naming convention. The tidy-up happens afterward, so the system works even for the colleague who never reads the shared guidelines or the pinned instructions.

  • Duplicates reviewed by a person

    Nothing is deleted automatically. A report lists the copies together, so someone confirms which version is the original before anything is trashed, which avoids accidental loss of a file that only looked identical.

  • A sorted archive for audits and handovers

    When a team member leaves or an auditor asks for documents, a folder organized by type and date can be handed over as it is, instead of needing a week of cleanup first.

How it works

What happens, step by step

  1. Every hour or day ClickRuntime looks at the files in your Google Drive uploads folder.

  2. It moves each file into the right subfolder by type, such as PDFs, images or documents.

  3. It checks for files that are exact copies of each other.

  4. If it finds any, you get an email listing each duplicate and how many copies there are.

Before it runs live

  • Connect Google Drive

What you get

RunsHourly or daily
Keep your uploads folder sortedtoday, 9:00Succeeded
Email · 1 duplicate files in InboxAcme-contract.pdf (182340 bytes) x2

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Google Drive steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
drive_housekeeping_rename_sort_de_duplicate.pyexample
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from collections import defaultdict
from clickruntime import on_trigger, credentials, notify

INBOX = "inbox-folder-id"
SUBFOLDERS = {"pdf": "pdfs-folder-id", "image": "images-folder-id", "doc": "docs-folder-id"}

def kind(mime):
    if mime == "application/pdf":
        return "pdf"
    if mime.startswith("image/"):
        return "image"
    return "doc" if "document" in mime or "word" in mime else None

@on_trigger
def run(event):
    drive = build("drive", "v3", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    files = drive.files().list(q=f"'{INBOX}' in parents and trashed = false",
                               fields="files(id,name,mimeType,size,createdTime)").execute()["files"]
    groups = defaultdict(list)
    for f in files:
        groups[(f["name"], f.get("size"))].append(f["name"])
        name = f["name"] if f["name"][:4].isdigit() else f"{f['createdTime'][:10]}_{f['name']}"
        target = SUBFOLDERS.get(kind(f["mimeType"]))
        drive.files().update(fileId=f["id"], body={"name": name}, addParents=target,
                             removeParents=INBOX if target else None).execute()
    dupes = [f"{name} ({size} bytes) x{len(v)}" for (name, size), v in groups.items() if len(v) > 1]
    if dupes:
        notify.email_me(f"{len(dupes)} duplicate files in Inbox", "\n".join(dupes))
    return {"sorted": len(files), "duplicates": len(dupes)}

FAQ

Common questions

How does it tell that two files are duplicates?
It compares the md5Checksum that Drive stores for each file, which is a fingerprint of the content. Two files with the same checksum are byte-for-byte identical, even if their names differ. Native Google Docs and Sheets have no checksum, so they are not compared this way.
Will moving files break links people have shared?
No. Moving a file in Drive changes its parent folder but not its ID, so existing share links and embedded references keep working. Renaming also leaves the link intact. People may be surprised that the file is in a new place, though.
Can files be sorted by something other than type?
Yes. You can sort by owner, by year and month taken from the file date, or by a keyword in the name such as invoice or receipt. Describe the rule you want, review the preview your assistant shows, and approve it.
What permissions does it need?
read+write (drive). Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (hourly or daily). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Keep your uploads folder sorted” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.