Skip to content

Every 15 minutes

Sort a OneDrive folder by file type

New files in your catch-all folder move into PDFs, Images or Other subfolders.

Runs
Every 15 minutes
Apps
OneDrive
AI
Not needed
Access
read+write

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, move new files in OneDrive Inbox into the subfolders PDFs, Images or Other based on file type.

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

A freelance designer's OneDrive Inbox folder gets everything: client PDFs, screenshots synced from a phone, Excel quotes, zipped assets, voice memos and a pile of JPGs named IMG_4821. Finding last quarter's proposal means searching through hundreds of unsorted files, and a rushed Friday afternoon cleanup never finishes. The mess slows every search and makes shared folders look unprofessional to clients.

Every 15 minutes, the contents of the inbox folder are listed, each file's extension is matched against a map (PDFs to Documents, JPG and PNG to Images, XLSX and CSV to Spreadsheets, MP3 and M4A to Audio, ZIP to Archives), and each file is moved to the matching subfolder by updating its parent folder in OneDrive.

It is a good fit for downloads folders, shared drop folders and scanned-document inboxes.

What you get out of it

  • Files are findable without searching

    A predictable folder for each type means that browsing works. You know that quotes are in Spreadsheets, and you do not need to remember how a file was named. Searching by memory, by date or by a vague name becomes unnecessary because the folder itself narrows the search.

  • The cleanup never gets postponed

    A manual sort is the sort of job that slips for months. Doing it every quarter hour keeps the inbox nearly empty, which means it always looks tidy. In a business where speed counts, a short search means a quicker reply to a client who is waiting.

  • Shared folders look professional

    When clients or partners open a link to your drive, a folder of organized subfolders makes a better impression than a flat list of mixed files. That also saves you from the embarrassment of a client scrolling past your private screenshots to reach the folder they need.

  • Space problems are easier to spot

    Once archives and videos sit in their own folders, it is simple to see which type consumes the most storage and to clear it out. A tidy structure also makes it easier to delete clutter confidently, since you can see what you have.

  • Less risk of misplaced documents

    Contracts and invoices no longer vanish among screenshots, so important PDFs are in one predictable location when an audit or a deadline arrives. It saves the stressful minutes before a deadline, when you need that signed file and cannot find it.

How it works

What happens, step by step

  1. Every 15 minutes, ClickRuntime checks your catch-all OneDrive folder for files.

  2. It looks at each file's type: PDFs, images or anything else.

  3. Each file is moved into the matching PDFs, Images or Other subfolder, so the folder stays tidy.

Before it runs live

  • Connect OneDrive

What you get

RunsEvery 15 minutes
Sort a OneDrive folder by file typetoday, 9:00Succeeded
OneDrive · Inboxreceipt-acme.pdf → PDFs · site-photo.jpg → Images · notes.txt → Other

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

  • Act only on the items that match your own rules, and skip the rest
  • 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 OneDrive 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.
auto_sort_new_files_by_type.pyexample
from clickruntime import on_trigger, credentials, http, report_fetched

GRAPH = "https://graph.microsoft.com/v1.0"
INBOX = "Inbox"
TARGETS = {"PDFs": (".pdf",), "Images": (".jpg", ".jpeg", ".png", ".gif", ".heic")}

@on_trigger
def run(event):
    h = {"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}
    files = [i for i in http.get(f"{GRAPH}/me/drive/root:/{INBOX}:/children", headers=h).json()["value"] if "file" in i]
    report_fetched(len(files))
    if not files:
        return {"summary": "Nothing new"}
    folder_ids = {name: http.get(f"{GRAPH}/me/drive/root:/{INBOX}/{name}", headers=h).json()["id"] for name in [*TARGETS, "Other"]}
    for f in files:
        dest = next((name for name, exts in TARGETS.items() if f["name"].lower().endswith(exts)), "Other")
        http.patch(f"{GRAPH}/me/drive/items/{f['id']}", headers=h, json={"parentReference": {"id": folder_ids[dest]}})
    return {"sorted": len(files)}

FAQ

Common questions

What happens to files with an unknown extension?
Anything not on the map stays in the inbox, or goes to an Other folder if you prefer. Nothing is deleted. Files without an extension are treated the same way. The extension map is a short list that can be extended with your own file types at any time.
Does moving files break links that I shared?
OneDrive links created through Share are tied to the file itself, so they normally keep working after a move within the same drive. Direct links that contain the folder path would break, so check any you pasted into documents.
Can it sort by sender or project name instead of type?
Rules can be based on file name patterns too, such as files starting with a client code going to that client's folder. Type is the default, and name-based rules can be added alongside it. Pairing the two approaches is common, such as type folders inside client folders.
What permissions does it need?
read+write. 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 checks. Checks that find nothing new 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 “Sort a OneDrive folder by file type” from your assistant

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