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!
- SharePoint error - Your organization doesn't allow sharing with users from this domain. Please contact your IT department for help. (OSE403)
- Restore deleted Office 365 SharePoint group site
- SharePoint error cannot connect to the configuration database
- How to open SharePoint Online Modern SPFX links in new tab
- Show Hide SharePoint column in List Library form with the conditional formula
- SharePoint Server 2016 installation System Hardware requirements
- SharePoint installation - Appfabric installation failed because installer MSI returned with error code:1603
- SharePoint installation error - Setup is unable to proceed due to the following error This product requires Microsoft .Net Framework 4.5
- Get count of SharePoint List or Document Library Items using PowerShell
- Sign in as different user missing in SharePoint 2013, how to enable
- Unable to load VM from snapshot. The snapshot has been saved for a different hardware configuration - Android
- Get Wifi Details : Android Programming - Android
- JSON Syntax : JSON Tutorial - Json-Tutorial
- Word count in Notepad++ - NotepadPlusPlus
- SharePoint Server 2016 error - Failed to connect to the configuration database - SharePoint
- Android Alert Dialog with Checkboxes example - Android
- java.lang.NoClassDefFoundError android.support.v4.content.LocalBroadcastManager - Android
- [Notepad++] Remove CR Carriage Return and LF Line feed (CRLF) - NotepadPlusPlus
- Failed to install Android.apk on device 'emulator-5554': timeout - Android-Studio
- How to get Mobile Screen Resolution Width and Height programatically - Android
- Tomcat Manager Default Username and Password - Tomcat
- Turning Off Chat in Gmail - Google
- [Solved] SharePoint Illegal operation attempted on a registry key that has been marked for deletion - SharePoint
- Find Sum of two numbers - C-Program
- Struts 2 Hello World Example in Eclipse - Java