Sheila,
I needed something similar so I modified Jacob's SDK script a bit. You will want to replace the for loop that looks like this:
for (int i = 0; i < history.Count; ++i)
{
DocumentVersion version = history[i];
// replace "Workflow" with your Workflow User
if (version.Creator == "Workflow")
{
// write an appropriate note for why this version is being deleted
version.Delete("This version was deleted because it was created as part of a workflow.");
}
}
With something that looks like this:
for (int i = 0; i < history.Count -5; ++i)
{
DocumentVersion version = history[i];
//Previously deleted versions have Comment = Deleted
if (version.Comment != "Deleted")
{
//Set Comment = Deleted and delete version
version.Delete("Deleted");
}
}
Just make sure if you edit the delete comment to also edit it in the IF statement.