If you don’t feel like manually deleting empty folders, use this PowerShell script to query and delete all empty folders and subfolders. Make sure you change the $WebURL to your SharePoint site or subsite, and the $listName to your library.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue function EmptyFolders() { $WebURL = "http://sp2013/sites/company" $webDestination = Get-SPWeb -identity $WebURL $listName = "Documents" $query = New-Object Microsoft.SharePoint.SPQuery; $query.ViewAttributes = "Scope='RecursiveAll'"; $query.RowLimit = 5000 $caml = "<Where> <Eq> <FieldRef Name='ContentType' /> <Value Type='Text'>Folder</Value> </Eq> </Where>" $query.Query = $caml $list = $webDestination.Lists[$listName] $folder = $list.GetItems($query) do { $query.ListItemCollectionPosition = $folder.ListItemCollectionPosition for ($index = $folder.Count - 1; $index -gt -1; $index--) { if ($folder[$index]["FolderChildCount"].Replace(';#', '') -eq 0 -and $folder[$index]["ItemChildCount"].Replace(';#', '') -eq 0) { Write-Host("$($folder[$index]["FolderChildCount"].Replace(';#', '')), $($folder[$index]["ItemChildCount"].Replace(';#', '')), $($folder[$index]["ContentType"]), $($folder[$index].URL)") $folder[$index].Delete(); $list.Update() } } } While($query.ListItemCollectionPosition -ne $null) #$list.Update(); $webDestination.Dispose() $wshell = New-Object -ComObject Wscript.Shell $wshell.Popup("Operation Completed",0,"Done",0x1) } EmptyFolders
Appreciating the persistence you put into your site and detailed information you present. It’s great to come across a blog every once in a while that isn’t the same unwanted rehashed information. Excellent read! I’ve saved your site and I’m including your RSS feeds to my Google account.
Thanks a bunch for sharing this with all people you really know what you are talking about! Bookmarked. Kindly also consult with my web site =). We can have a link change agreement between us|
replique bagues cartier femme or http://www.bestlovegift.nl/high-imitation-cartier-love-white-gold-ring-narrow-version-for-men-and-women-p122/
Greetings! Very helpful advice in this particular post!
It is the little changes which will make the biggest changes.
Many thanks for sharing!
Good post. I learn something totally new and challenging on websites
I stumbleupon on a daily basis. It’s always interesting to read through articles from other authors and use a little something from other
web sites.
Thanks very nice blog!
Thank you, I have just been looking for info approximately this topic for a while and
yours is the greatest I’ve discovered so far.
But, what about the bottom line? Are you sure about the source?