SharePoint Online Deletion of Non-Empty Folders

Folder Deletion with Items in Place Makes it Easier to Clean Out Old Material

In the past, SharePoint Online used to block deletion of files with retention labels. In late 2021, Microsoft decided to make the deletion behavior consistent across SharePoint Online and OneDrive for Business by allowing deletions to occur. Files with retention labels went into the site recycle bin and progressed into the preservation hold library until their retention period expired. After that point, a timer job finds and removes the expired files.

Another welcome change to SharePoint deletion behavior is now rolling out (MC791878, 11 May 2024, Microsoft 365 roadmap item 394689) and should be fully deployed worldwide around this time. The change allows users to delete folders in document libraries that aren’t empty in sites covered by a Purview retention policy.

Removing Old Material with Folder Deletion

This doesn’t sound important, but being able to delete folders without having first to open the folder and remove all the files stored there is the way things should have worked all along. A case can be argued that allowing people to delete folders without checking what’s stored in the folder could lead to inadvertent removal of information.

However, the case is undermined by the fact that the deleted folder (and its items) goes into the recycle bin from where it can be recovered. Even if the deleted folder passes through the normal SharePoint Online recycle bin cycle, administrators can still rescue the files from the site preservation hold library. When a deleted file is restored from the recycle bin, SharePoint Online recreates the folder in the original location if necessary.

The only problem I met testing deletions is when attempting to delete an empty folder and a non-empty folder together. For some bizarre reason, SharePoint Online used the old behavior and refused to remove the non-empty folder (Figure 1). SharePoint Online was quite happy to remove the same folder if processed individually.

Folder deletion runs into a problem.
Figure 1: Folder deletion runs into a problem

Very importantly, after deleting a non-empty folder, OneDrive for Business will not attempt to synchronize the deleted folder back from its offline copy.

Checking Retention Status for SharePoint Sites

If a tenant uses multiple retention policies, it can be challenging to determine which policy governs an individual site or mailbox. To help, the Data lifecycle management section of the Purview compliance portal includes a policy lookup option. At first glance, the list of retention policies shown in Figure 2 seems overwhelming, but several different types of policy are present, including some to publish retention labels to the site and auto-label policies that use trainable classifiers to label files with certain characteristics.

Checking retention policies for a SharePoint Online site.
Figure 2: Checking retention policies for a SharePoint Online site.

Because multiple policies can have a specific site within their scope, it’s important to note the purpose of each policy in the description.

Why is it Important to have easier Folder Deletion?

Some people never delete any material from SharePoint Online. At least, they don’t until they’re forced to because the tenant storage quota is nearly exceeded, and they want to avoid purchasing some expensive additional storage. The problem here is that deleting non-empty folders in sites governed by retention policies won’t help with a storage quota issue because files retained in the preservation hold library count against the quota. In some cases, the preservation hold library can occupy 40% or more of the storage used by a site.

It’s wise to keep an eye on the storage consumed by sites and then investigate the sites where storage consumption seems excessive. I use a Graph-based PowerShell script to generate a report of individual files in a document library to help understand where storage is eaten up. Obviously, after identifying unwanted files and folders, being able to remove those files more easily is a good thing.

Another reason why it’s good to clean up document libraries is that it stops Artificial Intelligence tools like Copilot for Microsoft 365 using old, obsolete, and potentially inaccurate information. Removing digital debris is something I think we’re all going to become more serious about as the AI era unfolds.


Keep up to date with developments like the AI era for Microsoft 365 by subscribing to the Office 365 for IT Pros eBook. Our monthly updates make sure that our subscribers understand the most important changes happening across Office 365.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.