Console Application to Delete and/or Recycle File versions in a MOSS 2007 Publishing Site

A while back, I wrote a console application that helped me cleanup file versions in a publishing site collection just before we went live with the site. This console application was sitting on my laptop for the longest time till now. This application evolved into an STSADM Extension. This blog entry represents the work done prior to that, sorry 😦 Hopefully in the near future, I can try to write it in PowerShell and post it back here.

Disclaimer

BIG disclaimer here. What I am trying to describe here in this post falls in a time period before MOSS SP1. Code is not 100% clean. Code is not rock solid. Please feel free to provide feedback.

Problem

The problem was simply to try to delete and recycle all file/page versions just prior to site go live. We didn’t want to keep old versions of files that we don’t need and take up space in the database. The other part of the problem, is simply forgetting or not planning for version control. A bunch of libraries in a MOSS 2007 publishing site come (by default) with versioning enabled, but not necessarily configured. We didn’t configure version control prior to content authoring.

Solution

This code tries to connect to the site collection in question after validating it, iterates through its sub sites and clean up file versions.


<Code>Was removed due to it’s ugliness… I will repost later.</Code>


Usage

Say you compiled the above code snippet successfully, you should be able to do something like this:

RecycleOrDeleteFiles.exe -o recycleall -url http://sharepoint -folders pages,sitecollectionimages,_catalogs -includesubfolders

Resources

Some resources that were used to develop this solution:

SPFile – http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfile.versions.aspx

SPFolder – http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.aspx

SPFarm – http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spfarm.aspx

Advertisements

About jharbieh

I'm an IW Solutions Architect with background in requirements gathering, planning, design, architecture, and development (not necessarily in the right order). Currently, my focus is on the Microsoft Productivity and Collaboration space. Hope you enjoy what I write about here. Thanks for visiting. Johnny Harbieh
This entry was posted in SharePoint Development. Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s