Answered by:
SharePoint 2007 - Document Library - Deleting All Versions in Bulk

>
Question
-
I manage a MOSS 2007 enterprise server that has a site collection with about 5k documents in the document library. The docs are mainly PDFs and there are anywhere from 3 to 10 versions of the each, which we do not need & are just taking up valuable database space. The person who set up the site left versioning on w/ no limits, which I have since turned off. I wanted to know if there's an easier way to delete those old versions w/o manually open each doc in the site content & structure tool and clicking the deleting all versions link and then emptying the recycle bin to release the space in db. I saw there was a tool for MOSS 2003, but can't find anything similar for MOSS 2007.Friday, June 19, 2009 8:10 PM
Answers
-
Hi,
If you set the number of versions that a document library should have, then the next time someone goes to upload a document, that document will delete all previous versions up to the number you specified.
Example: If you a document in a library has 50 versions, then you modify the settings to 3 major versions only. If you look at the document's version history you will still see all 50 versions. If you upload a new version of that same document then 47 versions dissapear and you have the 3 versions that you want.
Here is an article that explains this.
http://www.sharepointblogs.com/agoodwin/archive/2008/04/01/how-to-delete-historical-document-versions-in-wss-3-moss-not-entirely-simple.aspx
Hopefully that helps.
Sincerely,
Karl- Marked as answer by Mike Walsh FIN Saturday, June 20, 2009 10:34 AM
Friday, June 19, 2009 9:24 PM
All replies
-
Hi,
If you set the number of versions that a document library should have, then the next time someone goes to upload a document, that document will delete all previous versions up to the number you specified.
Example: If you a document in a library has 50 versions, then you modify the settings to 3 major versions only. If you look at the document's version history you will still see all 50 versions. If you upload a new version of that same document then 47 versions dissapear and you have the 3 versions that you want.
Here is an article that explains this.
http://www.sharepointblogs.com/agoodwin/archive/2008/04/01/how-to-delete-historical-document-versions-in-wss-3-moss-not-entirely-simple.aspx
Hopefully that helps.
Sincerely,
Karl- Marked as answer by Mike Walsh FIN Saturday, June 20, 2009 10:34 AM
Friday, June 19, 2009 9:24 PM -
You can use either Object model code or PowerShell to delete versions,
$SPweb = Get-SPWeb "http://SharePointSite.com" $versionsToKeep =5; $SPlist = $SPweb.Lists["Tasks"] foreach ($SPitem in $SPlist.Items) { $currentVersionsCount= $SPItem.Versions.count if($currentVersionsCount -gt $versionstoKeep) { for($i=$currentVersionsCount-1; $i -gt $versionstoKeep; $i--) { $SPItem.versions[$i].delete() } } }
More info: http://salaudeen.blogspot.co.uk/2011/01/limitcleanup-versioning-in-sharepoint.html- Proposed as answer by David McKenzie Tuesday, October 9, 2012 2:25 PM
Tuesday, April 10, 2012 7:35 AM -
This solution has the the potential to destabilize your system for a time, as I have experienced and reproted.
Note that the next *user* to update an item takes the hit.
Salaudeen Rajack's code solution below is recommended for larger numbers of versions.David McKenzie
Tuesday, October 9, 2012 2:30 PM