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.
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
Every week, ClickRuntime looks through the files in your chosen OneDrive folder.
It picks out the ones that have not been changed for months.
It moves them into your Archive folder.
You get an email listing each file that moved and when it was last changed.
Before it runs live
- Connect OneDrive
What you get
Build your own
Need it to work differently?
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
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?
How is age worked out?
Can some files be protected from cleanup?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Back up an export to OneDrive every night
A dated copy of your data export is saved nightly, older copies are pruned, and you hear if it fails.
See how it worksRefresh a workbook in OneDrive every day
A workbook stored in OneDrive gets fresh values daily and you get the new total.
See how it worksGet a weekly OneDrive storage report
Each Monday you see how much storage you're using and which files changed last week.
See how it worksKeep exploring
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.