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: