How to Fix Cannot Delete Empty SharePoint Folder Error
Question details
The user is unable to delete or rename an apparently empty folder in SharePoint due to an error stating that all items must be deleted first.

- Product
- SharePoint
- Device & OS
- not provided
- Scenario
- Attempting to delete or rename an empty folder in a SharePoint document library.
- Observed behavior
- SharePoint displays an error saying 'You have to delete all the items in this folder before you can delete the folder.' When attempting to rename it, an error states 'Cannot lock file. Either the file is in use or the web server is temporarily busy.'
Ensure you have the necessary site permissions to delete folders in the SharePoint library. Modifying retention policies requires a Microsoft 365 administrator account.
Check and Temporarily Disable Retention Policies
Identify and temporarily disable any retention policies, Preservation Hold Libraries, DLP policies, or eDiscovery holds that are locking the folder.
When a SharePoint site is governed by a retention policy or eDiscovery hold, items cannot be deleted or modified freely to ensure organizational data compliance. Even if a folder appears entirely empty, these hidden holds can prevent its deletion or renaming.
Sign in to the Microsoft Purview portal using your Microsoft 365 administrator account credentials.
Navigate to the Data Lifecycle Management, Data Loss Prevention (DLP), or eDiscovery sections to review the active policies applied to your organization's sites.
Identify the specific retention policy or hold that is currently applied to the affected SharePoint site.
Temporarily disable the policy or exclude the specific SharePoint site from the policy rules, ensuring this aligns with your organization's data governance guidelines.
Wait for the policy changes to propagate across the server, and then attempt to delete or rename the empty folder again.

Rebuild the Folder Structure
If the retention policy cannot be disabled due to compliance reasons, rebuild your folder structure around the locked folder.
Looking for a Seamless Office Alternative? Try WPS Office
While SharePoint and Microsoft 365 administrative policies can be complex to manage, your daily document creation shouldn't be. WPS Office offers a free, lightweight, and highly compatible alternative to the Microsoft Office suite, allowing you to create, edit, and collaborate on Word, Excel, and PowerPoint files with zero hassle.

Frequently Asked Questions
Why does SharePoint say 'Cannot lock file' when I try to rename an empty folder?
This error generally occurs when the folder is subject to a Preservation Hold Library or a retention policy. The server perceives the file or folder as 'in use' or locked by the system to prevent unauthorized modifications or deletions.
How can I tell if a retention policy is applied to my SharePoint site?
If you navigate to your SharePoint 'Site Contents' and see a 'Preservation Hold Library' listed among the contents, it is a strong indicator that a retention policy or legal hold is currently active on your site.
Do I need administrator rights to delete a folder locked by a retention policy?
Yes, standard users cannot bypass organizational retention policies. You must contact your Microsoft 365 administrator to review, adjust, or temporarily disable the settings within the Microsoft Purview portal.
How long does it take for retention policy changes to apply?
After an administrator disables or modifies a retention policy, it can take anywhere from a few hours up to 24 hours for the changes to fully propagate through the Microsoft 365 and SharePoint systems.




