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.


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.


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.


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>


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


Some resources that were used to develop this solution:

SPFile –

SPFolder –

SPFarm –


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 Cloud, 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: Logo

You are commenting using your 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