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.
⛏️ SOLUTION
The 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!
- SharePoint error - An exception occurred when trying to issue security token: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms..
- PowerShell iterate and get all SharePoint sites and sub sites
- SharePoint Online: Editing session has ended Message
- How to Share Microsoft SharePoint Site with Users or Groups
- How to delete SharePoint Online List Item using REST API
- SharePoint List excel import - This table exceeds the maximum number of supported rows
- How to disable SharePoint subsite creation option for owners
- SharePoint 2010 August 2015 Update KB3055049 - Duplicate Document ID issue bug fixed
- SharePoint Server 2016 Preview installation error - This Product Key isn't a valid Microsoft Office 2016 Product Key. Check that you've entered it correctly.
- How to upload file programmatically to SharePoint Document Library using Server Object Model C# .Net
- Access URL for SharePoint Tenant Admin Center (Online Office 365)
- Error when deleting SharePoint Online folder or file
- How to extend retiring SharePoint 2010 Workflows and continue with Office 365
- How to generate client id and secret to register SharePoint App with OAuth
- How to delete SharePoint List Item programmatically using C#.Net
- How to retrieve all SharePoint Online List Items using Rest API
- [Solved] SharePoint Search Internal server error exception
- Create SharePoint Site Collection using PowerShell New-SPSite
- Fix SharePoint PowerShell error - The term Get-SPweb is not recognized as the name of a cmdlet function script file or operable program
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- SharePoint Server 2016 installation System Hardware requirements
- How to create SharePoint Online List Item using REST API
- Changed AD user display name showing old name in SharePoint
- Recommended size and resolution for SharePoint Online Site logo
- Microsoft 365: How to Turn Off Delve in SharePoint Online for All Users
- How to check your installed version of Git - Git
- Notepad++ select all above or below lines - NotepadPlusPlus
- [Mac] How to Mute People in a Microsoft Teams Meeting - Teams
- Android Studio Button onClickListener Example - Android-Studio
- How to come out of Full Screen Mode Roblox on Mac - MacOS
- How to change background color in Notepad++ - NotepadPlusPlus
- Mac - Open Finder App using Terminal Current Location - MacOS
- How to change SharePoint Online site collection or subsite URL address - SharePoint