3

I have a SharePoint folder where I accidentally dropped a folder with a many subdirectories and files. I would like to delete it all by deleting the top level folder, however I keep getting an error since the folder is full of files.

You have to delete all the items in this folder before you can delete this folder.

Is there any way to force delete the folder even though it contains many files?

2
  • can you tell us what technology are you using? Full Rest, CSOM, JSOM, Client Object...
    – Marco
    Commented Apr 18, 2019 at 15:51
  • 1
    I really don’t know. We have a Microsoft 365 office sharepoint folder. I interact with it via the web interface.
    – Sledge
    Commented Apr 18, 2019 at 16:36

2 Answers 2

3

If you or your admin knows PowerShell, you can use the SharePoint PNP library to delete the folder:

#if not already installed
#install-module sharepointpnppowershellonline   #requires PS 4.0 or later.

Connect-PnPOnline -Url https://yourServer/sites/yourSite
Remove-PnPFolder -name Test -Folder "/shared documents"  

 

You may see recommendations to use the SharePoint "Sync" feature. Don't. This is a real overkill for just deleting a single folder, and opens up some interesting risks to other site data.

 

You can use Windows Explorer and map the library to a drive letter. You then display the library in Windows Explorer, click the folder and click Delete. (The items will be sent to the recycle bin.)

Windows Explorer can be very finicky and works for some and not others. You may need to logon to the site with Internet Explorer first. Do a web search with your windows version, browser version and error message for help.

Basic steps:

  • Open Windows Explorer
  • Right-click the Network folder/icon
  • Click Map Network Drive
  • Click "Connect to a Web site that you can use to store your documents and pictures"
  • Click "Choose a custom location" and click Next.
  • Enter the URL to your library. (Just the library, not a view: https://yourServer/sites/yourSite/Shared Documents)
  • Click Next and enter a name and then click Finish.
  • Windows Explorer should open with your library displayed.
  • Delete the folder
2
  • Should also add that I am using a Mac, so not sure if these solutions will work for me. Still good ideas and I'll try to find the Mac equivalent.
    – Sledge
    Commented Apr 18, 2019 at 18:30
  • There is a PowerShell for Mac, but I don't think the PNP cmdlets will work there. Can you login to your SharePoint from a Mac, or enlist the help of someone in IT? Commented Apr 18, 2019 at 18:36
2

I found out for us where this error affects the Sharepoint Online web interface when we (admin) have an eDiscovery case open or litigation hold policy applied on the folder. It only happens on the web interface and you can delete the folder and all its sub-items if you deleted it through the OneDrive sync client or through "Open with Explorer" (IE only).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.