locked
How to find unused documents and create a list? RRS feed

  • Question

  • I've been asked to send a report to users with a list of path/documents that have not been accessed within the past two years, so we can request their deletion.

    I'm finding some information on how to do this for unused sites, but not documents.

    Thanks!

    Scott


    • Edited by scogordo Friday, May 10, 2013 4:40 PM
    Friday, May 10, 2013 4:39 PM

Answers

  • Hi,

    I have seen similar request. This can be achieved using custom code to filter the audit log reports. You can store the report in a document library then search the report for document which haven’t been used in two years.

    SPList dokumentlist = website.Lists["Dokument"];

                    foreach (SPListItem item in dokumentlist.Items)

                    {

                        SPAuditEntryCollection auditcoll;

                        auditcoll = item.Audit.GetEntries();

                        foreach (SPAuditEntry entry in auditcoll)

                        {

                            if ((entry.Event == SPAuditEventType.AuditMaskChange || entry.Event == SPAuditEventType.View) && entry.Occurred.CompareTo(DateTime.Now.AddYears(-2)) == -1)

                            {

                                string emailBody = "This document has not been using for a 2 years: " + item.Web.Url + item.Url;

                                SPUtility.SendEmail(website, false, false, "admin@web.com", "Subject", emailBody);

                            }

                        }

                    }

    For more detailed information, please refer to this site:

    Send e-mail to admin of unused (never opend) sharepoint documents: http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/Q_25017343.html (the answer is at the bottom of the page).

    Thanks,

    Entan Ming

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contacttnmff@microsoft.com.

    Entan Ming
    TechNet Community Support

    • Marked as answer by Emir Liu Friday, May 17, 2013 11:02 AM
    Monday, May 13, 2013 2:32 AM
    Moderator

All replies

  • Hi,

    I have seen similar request. This can be achieved using custom code to filter the audit log reports. You can store the report in a document library then search the report for document which haven’t been used in two years.

    SPList dokumentlist = website.Lists["Dokument"];

                    foreach (SPListItem item in dokumentlist.Items)

                    {

                        SPAuditEntryCollection auditcoll;

                        auditcoll = item.Audit.GetEntries();

                        foreach (SPAuditEntry entry in auditcoll)

                        {

                            if ((entry.Event == SPAuditEventType.AuditMaskChange || entry.Event == SPAuditEventType.View) && entry.Occurred.CompareTo(DateTime.Now.AddYears(-2)) == -1)

                            {

                                string emailBody = "This document has not been using for a 2 years: " + item.Web.Url + item.Url;

                                SPUtility.SendEmail(website, false, false, "admin@web.com", "Subject", emailBody);

                            }

                        }

                    }

    For more detailed information, please refer to this site:

    Send e-mail to admin of unused (never opend) sharepoint documents: http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/Q_25017343.html (the answer is at the bottom of the page).

    Thanks,

    Entan Ming

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contacttnmff@microsoft.com.

    Entan Ming
    TechNet Community Support

    • Marked as answer by Emir Liu Friday, May 17, 2013 11:02 AM
    Monday, May 13, 2013 2:32 AM
    Moderator
  • Entan,

    Quick comment on that link, Experts Exchange needs a subscription to get into, which Scott may not want to set-up.

    Any chance you can post the solution here for us?

    Thanks,
    Steven


    Steven Andrews | SharePoint Professional | http://www.twitter.com/backpackerd00d | https://baron72.wordpress.com/

    Monday, May 13, 2013 9:46 AM
    Answerer