Skip to content

Weekly

Archive old files from a temp folder weekly

Files that have sat untouched for months move to Archive, and you get a list of what moved.

Runs
Weekly
Apps
OneDrive
AI
Not needed
Access
read+write (Files.ReadWrite)

Send this to your assistant

Create a ClickRuntime automation: every Sunday, move files older than 90 days in my OneDrive Temp folder to Archive and email me the list of what moved.

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 marketing team uses a OneDrive folder called Temp for quick exports, test uploads, draft screenshots and files someone needed for one meeting. Nobody owns it and nobody empties it. After a year it holds six thousand files, eats storage that counts against the plan quota, and contains old customer lists that should not still be lying around where any colleague with the link can reach them.

Once a week, the folder's contents are listed, every file whose last modified date is older than your cutoff (say 60 days) is moved to the recycle bin, and an email gives you the list of what was removed, with names, sizes and dates, so nothing disappears without a record.

It fits temporary folders, shared download areas, export dumps and any place where files are meant to be short-lived.

What you get out of it

  • Stale data does not linger

    Old exports with names and email addresses are a liability. Removing them on a schedule limits how long sensitive data stays within reach of people who no longer need it. Pruning old files each week limits how long outdated customer lists, personal data and drafts remain exposed in a shared folder.

  • Storage stops creeping up

    Large video exports and zipped assets quietly consume quota. Weekly pruning keeps usage flat, which can postpone an upgrade or the cost of extra space. Large video exports and zipped assets quietly consume quota, so removing them weekly can postpone an upgrade.

  • Cleaning no longer depends on a volunteer

    A task that nobody owns usually stays undone. A schedule gives the folder a caretaker, without anyone having to schedule a cleanup day. Because nobody has to schedule a cleanup day or volunteer, the job simply gets done every single week.

  • Deletions leave a trail

    The emailed list shows what was removed and when. If someone misses a file, you can find its name quickly and restore it from the recycle bin. That list is also a handy record for managers who need to know why a file they remember is gone.

  • A clearer folder is quicker to use

    With only recent files left, searching and browsing are fast, and people trust the folder to hold current material. It is the kind of folder people stop noticing, so a regular tidy-up is better than a sporadic one.

How it works

What happens, step by step

  1. Every week, ClickRuntime looks through the files in your chosen OneDrive folder.

  2. It picks out the ones that have not been changed for months.

  3. It moves them into your Archive folder.

  4. You get an email listing each file that moved and when it was last changed.

Before it runs live

  • Connect OneDrive

What you get

RunsWeekly
Archive old files from a temp folder weeklytoday, 9:00Succeeded
Email · Archived 3 files from ProjectsAcme pitch v2.pptx (last changed 2026-02-11) Northwind notes.docx (last changed 2026-03-04)

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 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.
folder_cleanup.pyexample
from datetime import datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, http, notify

GRAPH = "https://graph.microsoft.com/v1.0"
FOLDER, ARCHIVE_ID = "Projects", "01ABCDEF...archive"
DAYS = 180

@on_trigger
def run(event):
    h = {"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}
    cutoff = (datetime.now(timezone.utc) - timedelta(days=DAYS)).isoformat()
    items = http.get(f"{GRAPH}/me/drive/root:/{FOLDER}:/children", headers=h,
                     params={"$select": "id,name,lastModifiedDateTime,file", "$top": 200}).json()["value"]
    moved = []
    for i in items:
        if "file" in i and i["lastModifiedDateTime"] < cutoff:
            http.patch(f"{GRAPH}/me/drive/items/{i['id']}", headers=h, json={"parentReference": {"id": ARCHIVE_ID}})
            moved.append(f"{i['name']} (last changed {i['lastModifiedDateTime'][:10]})")
    if moved:
        notify.email_me(f"Archived {len(moved)} files from {FOLDER}", "\n".join(moved))
    return {"moved": len(moved)}

FAQ

Common questions

Are files permanently deleted?
They are moved to the OneDrive recycle bin, not erased immediately, so they can be restored from there while they remain within the recycle bin's retention period. The email lists each one in case you need to look.
How is age worked out?
By each file's last modified date in OneDrive, not its creation date. A file that was edited recently stays, even if it was created long ago. You set the cutoff in days. It is also worth noting that a file renamed or moved into the folder keeps its older modified date.
Can some files be protected from cleanup?
Yes. Subfolders, file names or types can be excluded, for instance a Keep folder, so permanent material placed in the same area is never touched by the weekly sweep. Excluded areas are skipped completely, so important files remain safe even if they are old.
What permissions does it need?
read+write (Files.ReadWrite). 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 (weekly). 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 “Archive old files from a temp folder weekly” from your assistant

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