Forum Discussion

Deleted's avatar
Deleted
May 29, 2018

File explorer - searches

I am preparing to move a complete document library from a network drive to OneDrive and SharePoint, but before I can do that, I would like to clean up old files.

In my folders there are more than 100.000 files going back 6-8 years or so. Is there an easy way to extract from file explorer a list of files that have not been moditied or opened in e.g. 3 years? Including data on creation date, last modified date, author, last modified by, and the location of the file (folder).

I would like to copy the list to Excel.

 

  • Micah Hibdon's avatar
    Micah Hibdon
    Brass Contributor

    You can try using a script like this in PowerShell, then working with the CSV file it creates in Excel to find the data you need.  It won't have everything you asked for, but should give you some data to work with.  Hope that helps!  

     

    Get-ChildItem C:\Users\<user>\Documents | Select Name, LastWriteTime, LastAccessTime | Export-Csv -Path C:\Users\<user>\Documents\FileList.csv -NoTypeInformation

    • Deleted's avatar
      Deleted
      Thanks. I will try this.
      I seem to have a problem with the naming of my folders - PowerShell doesn't accept folders with "-" in the name. Anyway to solve this?
      • Micah Hibdon's avatar
        Micah Hibdon
        Brass Contributor

        That is interesting, I don't think PowerShell should have issues with a "-" in the name.  I did notice that I didn't allow for that script to search down below the one level of the folder you list by name.  You can add the "-recurse" parameter to the command to search all levels below just the top level.  Hope this helps!  

         

        Here's the updated code:

         

        Get-ChildItem C:\Users\<user>\Documents -recurse | Select Name, LastWriteTime, LastAccessTime | Export-Csv -Path C:\Users\<user>\Documents\FileList.csv -NoTypeInformation

Resources