Skip to content

Purging a SharePoint list of all items and folders

February 18, 2007

I saw a posting on

microsoft.public.sharepoint.development_and_programming

requesting this, so I thought I would share here as well in case anyone needed this functionality.

The code contained in this file: SPPurgeList.txt, contains sample code to purge a list of all it’s contents and folders (Define WSSV3 for that).

(Update 03-07-2007: See this link as this SPIEFolder is now published at http://www.codeplex.com/SPPurgeList )

If you need to retain the list itself (Maintaining it’s original GUID) without killing the entire list and re-creating, you can use this code to purge the list contents.

It should work on any list or document library.  When I get a chance to really run it through the ringer, I may post it on my CodePlex site.

HTH!

- Keith Richie

Advertisement
6 Comments leave one →
  1. February 21, 2007 6:16 pm

    Another way of clearing a large library – WebDAV. Just Select All and delete, as per normal in Explorer. It’s not rapid, but it works.

  2. February 21, 2007 9:19 pm

    I agree, that is another good method, but users stand the chance of accidentally deleting the forms folder too.

  3. March 8, 2007 3:54 am

    Update, I have “Seen” the forms folder be deleted in Web Folders for V2 before, but it looks like a recent change to WebDAV is now preventing it. At one time, it would actually delete all the contents of the Forms folder, then stop at the end with “Cannot delete the forms folder”, but by then, all your contents were gone. Looks like that was finally fixed.

  4. February 16, 2008 8:23 am

    debtfree for debtfree for

Trackbacks

  1. Importing/Exporting SharePoint Document Libraries to/from the File System « Krichie - That SharePoint Guy
  2. SPPurgeList on CodePlex - Purging a SharePoint list of all items and folders « Krichie - That SharePoint Guy

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.