A document library starts as "this project's workspace" and becomes a permanent fixture long after the project closes. Multiply that pattern by every team, every year, and a SharePoint Online tenant accumulates years of files nobody reads but everyone pays for in storage quota.
Can SharePoint Online automatically delete old files by age?
SharePoint Online has no native auto-delete feature tied to file age alone. Automatic deletion requires either a Microsoft Purview retention policy or an external process such as PowerShell or a third-party tool - no setting in the SharePoint admin center removes files based on how long they have gone untouched. The five approaches below cover every realistic path from "no action" to "fully automated compliance deletion."
| Approach | File-level targeting | Filter by file age | Scales to 100k+ files | No scripting required | Preview before delete | Compliance audit trail |
|---|---|---|---|---|---|---|
| Purview retention policy | Yes | Partial (creation/modification date) | Yes | Config only | No | Yes |
| Microsoft 365 Archive | No (site-level only) | No | Yes | Yes | No | Partial |
| PowerShell (PnP) | Yes | Yes | Yes | No | Dry-run only | Via audit log |
| Space Master Bulk Delete | Yes | Yes | Yes | Yes | Yes | Via recycle bin |
| Manual review | Yes | By eye | No | Yes | Yes | No |
1. Microsoft Purview retention policies
Purview retention policies apply to SharePoint sites and libraries. Configure a policy with a "delete at end of retention period" action, and SharePoint removes content that has reached that age automatically. This is the only fully hands-off approach in the list: once the policy is in place, no human needs to trigger anything.
When this works well
Purview is the right tool when deletion is a compliance obligation. A policy that destroys financial records seven years after their creation date enforces that requirement consistently without relying on anyone to remember a schedule. The audit trail for policy-driven deletion is the strongest available: every deletion is recorded in the Microsoft 365 compliance portal with timestamps, policy identifiers, and the identity of the content that was removed.
Limitations for everyday file-age cleanup
Purview measures the retention period from the date a file was created or last modified, not from the date it was last accessed or opened. A file that was heavily edited three years ago and never touched since will not be caught by a creation-date rule alone. There is also no preview before deletion. Content that meets the policy criteria is removed automatically when the period expires. Microsoft 365 E3 licensing or above is required; tenants on Microsoft 365 Business Standard or Business Premium plans do not have access to Purview retention policies for SharePoint.
2. Microsoft 365 Archive
Microsoft 365 Archive moves entire inactive site collections to a cold-storage tier at a lower per-GB cost than the active tenant pool. Archived sites are read-only and can be reactivated on demand, though reactivation takes time measured in minutes to hours depending on site size.
When this works well
Archive suits complete project sites whose work is done. If a site served a project that finished two years ago and no one actively uses it anymore, archiving it removes it from the active quota pool, reduces cost, and preserves the content in case it ever needs to be referenced. No individual files need to be identified or evaluated.
Limitations for file-age cleanup
Archive operates at the site level. It cannot target old files within an active site that still has current users and fresh content alongside the stale material. The most common real-world situation - an active team site with a Documents library holding years of mixed current and outdated content - is not a good fit for Archive. For that scenario, one of the file-level approaches below is required.
3. PowerShell bulk deletion scripts
PnP PowerShell's Get-PnPListItem cmdlet supports CAML query filtering on date fields including Modified and Created. A script that queries for files older than a specified date and then calls Remove-PnPListItem on each result can clear thousands of files in one automated run.
PowerShell gives you precision control over what gets deleted, but it also gives you a loaded weapon with no built-in safety net. A filter error can remove far more than intended, with no preview to catch it first.
When this works well
PowerShell is the right tool when the cleanup target is precisely defined: for example, "delete every PDF in the /Archive subfolder of this specific library that was last modified before 1 January 2022." A one-off cleanup of that specificity is straightforward to script and validate with a CSV export before deletion runs. No additional licensing is needed.
Limitations
Scripts require scripting expertise and significant time to write, test, and validate safely. Each new cleanup scenario requires either a fresh script or modifications to an existing one. Running the same script across multiple sites or tenants requires additional wrapper logic. PowerShell also has no graphical preview: the recommended safety practice is to export matching results to a CSV and review them manually before the deletion loop runs, which adds meaningful effort to what may seem like a simple task.
4. Space Master Bulk Delete
Space Master's Bulk Delete tools let you filter files or list items using a combination of criteria including file extension, folder path, file size, and last-modified date. All matching items are shown in a results list before any deletion is confirmed. Nothing is removed until you explicitly trigger the operation after reviewing the preview.
See what Space Master includesBecause Space Master uses the standard SharePoint API, deleted files go to the site's recycle bin rather than being permanently destroyed immediately. If a cleanup run catches something it should not have, an admin can restore it from the recycle bin within the standard 93-day window. For bulk recovery of multiple items, Recycle Master searches and restores by filename, date, or user directly from the bin, which is far faster than scrolling through the SharePoint recycle bin interface. The combination of a visual preview step and recycle bin safety makes Space Master the practical choice for cleanup across active libraries where a mistake cannot be ruled out.
5. Manual review and delete
Someone opens a library, sorts by "Date modified," scrolls through the list, and removes files they recognise as outdated. This is how most SharePoint cleanup actually happens in organisations without a dedicated admin tool or a Purview policy in place.
Manual review works for small, well-understood libraries with a clear owner who knows the content. It does not work for libraries with tens of thousands of files, multiple contributors over many years, and no single person who knows what to keep. It also cannot be repeated consistently: two people doing a "manual cleanup" of the same library will make different decisions, which compounds the governance problem rather than resolving it.
Decision matrix
| Your situation | Best fit |
|---|---|
| Must delete records at a specific age for legal or compliance reasons | Purview retention policy |
| Entire project site is finished and inactive | Microsoft 365 Archive |
| One-off cleanup of a precisely defined file set, run by a technical admin | PowerShell (PnP) |
| Active site with a mixed-age library; need to remove old files safely with a preview | Space Master Bulk Delete |
| Cleanup needed across multiple sites or libraries in a single session | Space Master Bulk Delete |
| Small library with a clear owner who knows the content | Manual review |
Most real-world cleanup projects combine approaches. Purview handles scheduled compliance-driven deletions. Space Master handles ad-hoc cleanup of libraries that compliance policies were never designed to cover. PowerShell fills narrowly defined one-off gaps. The combination means each tool is doing what it is actually suited for rather than being stretched into scenarios where it becomes risky or impractical.
For a deeper look at how version history drives quota growth on active sites, see the version cleanup tools comparison. If the goal is site-level quota management rather than file-level deletion, the storage management options comparison covers the full picture.
Frequently Asked Questions
Does SharePoint Online automatically delete files after a set number of days?
No. SharePoint Online has no built-in auto-delete feature based on file age. Automatic deletion requires a Microsoft Purview retention policy (E3 licensing) or an external tool or script. No setting in the SharePoint admin center removes files based on how long they have been untouched.
Does deleting a file from SharePoint immediately free up storage quota?
No. Deleted files move to the SharePoint recycle bin, where they remain for up to 93 days and still count against the site collection's quota. Storage is only fully reclaimed after the file is removed from the recycle bin, either by automatic expiry or by an admin clearing it manually.
Can I recover files deleted during a bulk cleanup?
Files deleted recently will be in the SharePoint recycle bin for up to 93 days. Restore them from the recycle bin page or use Recycle Master to search and restore in bulk. Files removed by a Purview retention policy require admin-level eDiscovery access to the Preservation Hold Library and are subject to the configured hold window.