You may encounter an error while deleting a folder in SharePoint Online - You have to delete all the items in this folder before you can delete the folder.
This usually occurs when the folder has sub-folders or files within and the SharePoint site has the preservation ' On-Hold' policy enabled for DLP (data loss prevention). When the site is on hold, files can be deleted directly but folders cannot be deleted unless all sub-items are deleted.
⛏️ SOLUTIONThe error message hints a solution - delete all files/folders within the folder and then delete the main folder.
Here are few ways you can try, whichever is convenient.
- Disable the on-hold for the site from Microsoft 365 Security and Compliance center (required Global Admin permissions). You can re-enable after deleting the folder.
- Delete all the files and sub-folders manually.
- Use PowerShell to write a script, loop through all sub items, and delete them.
- Use "View in File Explorer" option to manually delete files, this will give you a desktop like feeling.
- Ensure you have no checked out files in the folder.
You may come also come across a strange behavior, getting the error 'You have to delete all the items in this folder before you can delete the folder' while deleting a SharePoint file.
This may happen when the library is corrupted (say due to migration) and files are treated as folders.
Check if you have a default Content-Type associated with the document library, if not, then add a default Content-Type "Document" and set it for the problematic file from the document properties screen.
The same steps apply to OneDrive for Business, if you face the same issue.
Have Questions? Post them here!
- Managed Metadata error - The data returned from the tagging UI was not formatted correctly
- How to generate client id and secret to register SharePoint App with OAuth
- Create SharePoint Site Collection with new Content database in existing web application
- Fix Error 2711 SQL RBS client - The installer has encountered an unexpected error. The specified Feature name ('Docs') not found in Feature table
- How to exclude results from SharePoint Search
- 'Edit Document' Requires a Windows Sharepoint Services-compatible application and Microsoft Internet Explorer 6.0 or higher
- [Solved] SharePoint Access Denied error editing Document Name
- Recommended size and resolution for SharePoint Online Site logo
- SharePoint Server 2016 IT Preview - new improved Features and Enhancements
- Restore deleted Office 365 SharePoint group site
- SharePoint An unexpected error has occurred - Correlation ID and PowerShell Merge-SPlogfile
- [Solved] SharePoint Search Internal server error exception
- SharePoint CAML query error - The XML source is not correct
- How to hide quick launch in SharePoint classic site
- Not receiving email notification alert in SharePoint Online workflow - Power Automate, FLOW
- Change SharePoint search results FullTextSqlQuery RowLimit 10000
- Fix Power BI error Access to the resource is forbidden when connecting SharePoint Online List as data source
- [Fix] Restricted View permission level missing in SharePoint Online site library
- How to upload file programmatically to SharePoint Document Library using Server Object Model C# .Net
- How to create classic site in SharePoint Online
- That did'nt work, Issue type User not in directory - SharePoint external access error
- Merge-SPlogfile PowerShell - SharePoint Correlation ID error
- Fix Power BI 404 not found error when connecting SharePoint Online List as Data Source
- SharePoint Server 2016 IT Preview Deprecated Removed features
- SharePoint error - An exception occurred when trying to issue security token: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms..
- How to check your installed version of Git - Git
- How to install Packages in Sublime Text Editor - Sublime-Text
- Transfer files between Android and Mac OS X using usb cable - Mac-OS-X
- Locate MainActivity Java or Kotlin file in Android Studio - Android-Studio
- HTML, HTML5. CSS, CSS3 Color Codes 2020 - Html
- How to run a Maven jar project from eclipse without tomcat - Eclipse
- Docker Desktop needs privileged access macOS - MacOS
- 10 Beginners Commands for macOS Terminal Usage - MacOS