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 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 a 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.
- SharePoint An unexpected error has occurred - Correlation ID and Merge-SPlogfile
- SharePoint list excel import error - Title is a required filed and can't be empty
- Send Email with attachment using SharePoint PowerShell, SMTP server
- Sharepoint errors were found when compiling the workflow
- How to update SharePoint List Item programmatically
- Merge-SPlogfile PowerShell - SharePoint Correlation ID error
- Get-ADUser PowerShell - Get AD user details using email address
- Restore deleted Office 365 SharePoint group site
- [Solved] SharePoint Access Denied error editing Document Name
- How to migrate SharePoint Designer 2010 workflow to Power Automate FLOW (Microsoft Office 365)
- 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