Delete all files & folders in a library
Clear a library's contents, keep the library
Empties a document library, or one subfolder inside it, without deleting the library. Preview it first to see the count; the run itself always asks you to confirm before anything goes.
What it does
- How many files and folders are in scope, and how much storage they hold, before anything goes.
- What a date limit would protect, if you only want to clear content older than a certain point.
- What actually happened, per item.
How it runs
- Sign in and pick the target. A library, or one folder inside it.
- Set the options. Recycle bin or permanent, and optionally only items older than a date.
- Preview (recommended). Counts what is in scope. Nothing is deleted at this point.
- Confirm, then it runs. Recycling asks you to confirm; permanent deletion shows a red warning first. Cancel offers Finish the current item, Stop now, or Keep running. Nothing is left half-written: an item is either done or not started.
How it works
The run reads every file and folder in the library, or under the one folder you picked, with a read that works on libraries larger than the list view threshold. Each row is tested against what you chose: the rows you ticked in the picker (ticking nothing means the whole target, and ticking a folder means everything inside it), any created-before or modified-before date, a name filter, and a size range. A size range applies only to files, and an item with no date is kept when a date filter is on. A preview takes the same walk and removes nothing; the run reads the library again when you approve, so it acts on what is there at that moment.
Files are removed first, as they are found, a small group at a time. Each one goes to the site recycle bin or, only if you chose permanent deletion, is deleted outright. Folders are held back until every file has been dealt with and are then removed deepest first, so a folder never goes before the folders inside it. With no filter on, every folder in scope is removed too, which leaves the library itself empty but in place. With any filter on, including a date, no folder is removed: removing a folder takes everything inside it, and a folder's own name, size or date says nothing about the files it holds, so a filtered run removes matching files one by one and leaves every folder standing.
SharePoint answers for each file and folder separately. One that cannot be removed, for example a checked-out file, is counted as failed with SharePoint's reason and the run moves on. One that has already gone when the run reaches it is counted on its own as already gone, not as a removal and not as freed space. If the read of the library stops part way, the files already read are still removed but no folder is, because the run has not seen everything inside them, and the result says the scan was incomplete.
Freed space is counted only from files this run actually removed. In recycle mode it stays on the site's quota until the recycle bin is emptied; in permanent mode it is released straight away. Before each group is sent, the run records on this computer what it is about to remove, then what happened to each item, and the report and history entry are built from that record, so a stopped run still accounts for what it removed. Every preview and every run, finished or not, goes into Report History. The library itself and its settings are never removed.
What you get
An Excel workbook, named like contoso-delete-library-20260901-142207.xlsx, kept in Report History whether or not you save it.
Deleted Items sheet
One row per file or folder, with what happened to it.
| Column | Example |
|---|---|
| Site | Contoso Projects |
| Path | Shared Documents/Clients/Northwind |
| Name | Proposal v4.pdf |
| Kind | File |
| Size (KB) | 3,045 |
| Status | Recycled |
Summary sheet
Scope, options, counts and totals.
What you need
- Write access to the library. Permanent deletion generally needs site collection administrator.
What it will not do
- The library itself is kept. Its folders are removed too, deepest first, unless the run has a filter such as a date, in which case every folder is kept.
- A checked-out file cannot be deleted. Those are reported rather than skipped silently.
- Recycled content still counts against quota until the bin is purged.