Script to delete files older than a day in Sharepoint document library

dhiraj picture dhiraj · Feb 6, 2009 · Viewed 13.4k times · Source

I need a script which can delete all files which are older than a day and this script needs to be invoked every day automatically in the Sharepoint server. How can i do this and any hints as how to write the script?

Answer

Corey Roth picture Corey Roth · Feb 20, 2009

I think an easier way to do it would be to create a site collection policy with an expiration. Set the retention period for one day. You can then attach the disposition workflow to your list which acn be used to clean these files up. You should be able to do all of this without writing any code.

Here is a link with more information about disposition workflow. http://office.microsoft.com/en-us/sharepointserver/HA101544291033.aspx

Thanks, Corey