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!
- Move Copy Migrate SharePoint OneDrive files folders to different site collection location
- How to generate client id and secret to register SharePoint App with OAuth
- How to share SharePoint site or document with all users in organization
- Get-ADUser PowerShell - Get AD user details using email address
- error CAML Query containing special characters
- Access URL for SharePoint Tenant Admin Center (Online Office 365)
- Fix SharePoint Error - The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started
- SharePoint - The URL is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.
- How to delete SharePoint List Item programmatically using C#.Net
- How to Share Microsoft SharePoint Site with Users or Groups
- JSON column formatting to preview SharePoint Online file on mouse hover
- SharePoint List redirect user after submitting form NewForm.aspx
- See actual SharePoint error exception modify web.config
- SharePoint Server 2016 IT Preview Deprecated Removed features
- How to create SharePoint Document Library
- How to Get or Set SharePoint Document ID _dlc_DocId using PowerShell
- How to disable SharePoint subsite creation option for owners
- PowerShell - How to use Try Catch Finally blocks for error exception handling (Windows/SharePoint)
- SharePoint error - Your organization doesn't allow sharing with users from this domain. Please contact your IT department for help. (OSE403)
- [Solved] SharePoint Search Internal server error exception
- How to wrap column text in SharePoint Online Modern List Grid View using JSON formatting
- How to extend retiring SharePoint 2010 Workflows and continue with Office 365
- Changed AD user display name showing old name in SharePoint
- How to hide or remove quick launch left navigation from SharePoint Online Modern site page
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- Disable EditText Cursor Android - Android
- How to Compare Strings in Bash - Bash
- How to Use Command Prompt on a Mac? - MacOS
- Calculate discount amount python code - Python
- Add Text at Start and End of Each Line Notepad++ - NotepadPlusPlus
- How to check if a String contains substring or a word using javaScript - JavaScript
- Java 8 Leap year check using Year class from java.time api - Java
- How to always show Bookmarks bar on Google Chrome Browser - Chrome