I'm having a workflow that creates alot of documents in a single library. I know I'm going to exceed the limit of 5000 pretty fast. Old documents can be deleted so the question is: Is there a simple way to delete old files automatically?

The best way would be if there where a option that sharepoint deletes the oldest items in the list if it exceed the list view threshold.

The only way I can think of is to run a timer job / scheduled task that runs every night and delete the oldest files if it exceed like 4000.

3 Answers 3


Deleting files is not an answer when a SharePoint library can contain millions of files without any performance issues. List View threshold is not about the number of items in a list. It is more about the views. The number of items returned by a particular view should not exceed it as it causes performance issues. You should instead look to filter your views so that they return data below threshold limit.

  • So if I understand you correct the list can have millions of items, but the view that renders all the items have the limit. But I cannot see how I can limit the view, only date could. And then I cannot get all the items. If I create a view called "all documents" and set the value [today] - 6 month ... the view would not show any items that are 9 month old. I cannot search after the item .. or could I?
    – Plexus81
    Commented Feb 26, 2015 at 9:15
  • Say you want to see files that have been created in Past 7 days. Then you can create a view a filter based on Created Date. The formula can be [Today]+7. Commented Feb 26, 2015 at 9:18
  • I already have 3 views.. (All documents, your documents, your last documents). The first view "All documents" would get the problem I think.
    – Plexus81
    Commented Feb 26, 2015 at 9:19
  • By default the library will have All Documents view with no filters. But that should not prevent us from either modifying this view or to delete this view. Commented Feb 26, 2015 at 9:22
  • But the problem is that I want to have that view. But the logic of deleting files would not be a good solution ether... Maby I just should set a date on "All documents". Another question: This is a standard doclib so if a person search after a document it would still be indexed ..
    – Plexus81
    Commented Feb 26, 2015 at 9:27

If you're using SharePoint 2010 or newer you could possibly look into Information Management Policy.

Policy and Retention in SharePoint Server 2010 - should still apply for SP2013 on-premise.

It is however date based. Otherwise a timerjob is a pretty solid alternative as you control the circumstances of when to do what.


You may consider creating a "Retention" Policy for your document Library :

Go to the doc lib settings, and choose "Information management policy settings". Then select "Enable Retention" and configure it by adding stages (you can send the file to the bin in one stage, after a given period from file creation).

If "Information management policy settings" is missing, try to activate the site collection feature "Library and Folder Based Retention".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.