none
How to get a list of all files and folders in a document library?

    Question

  • We're in the process of cleaning out some old document libraries. We would like to get a listing of folders/subfolders/files in each document library and transfer to a text, Word or Excel. Any ideas?
    Wednesday, September 18, 2013 4:28 PM

Answers

  • Would you be comfortable with your uses running batch files then?  If you were confident, you could write a short guide that shows them: -

    1. How to map a SharePoint library to a drive
    2. How to open command prompt and change directory to the mapped drive
    3. using the dir /s /b > print.txt

    Viola.

    Assuming that they don't struggle with copy and paste, that should get them started.

    • Marked as answer by Carltonw1 Thursday, September 19, 2013 3:25 PM
    Thursday, September 19, 2013 2:29 PM

All replies

  • You can get that information in various ways, the easiest way to do it is to export the library to excel using the button on the ribbon.

    You might need to create a new view to get all the items, you can create one that shows all items even if they are in folders.

    Wednesday, September 18, 2013 5:37 PM
  • Hi,

    one way of achieving that is by using Powershell

    You can use a script similar to this one to list all the files and folders recursively.

    $SPweb = Get-SPWeb –identity “<yourweb url>”
    
    write-host $SPweb.title ":" $SPweb.URL -ForegroundColor DarkMagenta
    
    
                foreach($list in $SPweb.lists)  # Iterate around all lists in a site
    
                {
    
                    foreach($item in $list.items)
    
                    {
    
                        Write-Host $item.Title
    
                    }
    
    
                    GetFiles($list.RootFolder)
    
                }
    
    Function GetFiles($folder)
    
    { 
    
       Write-Host "+"$folder.Name
    
       foreach($file in $folder.Files)
    
       {
    
           Write-Host "`t" $file.Name
    
       }
    
    
       # Use recursion to loop through all subfolders.
    
       foreach ($subFolder in $folder.SubFolders)
    
       {
    
           Write-Host "`t" -NoNewline
    
           GetFiles($Subfolder)
    
       }
    
     }
    

    In the example above we are iterate through all the lists on the selected web. But you can adapt the code to receive a list name or URL to list only the document from that specific list.

    Hope this help you.

    Thanks.

    Best regards,


    Nuno Costa

    Wednesday, September 18, 2013 5:41 PM
  • I'm able to change the view and show all of the documents, even those in folders, but I can't the folder name listed that it's under. How can I change the view so it shows the folder it's in as well?

    I'd like to give the user the capability to do this without having to script it.

    thanks.

    Wednesday, September 18, 2013 6:37 PM
  • Would you be comfortable with your uses running batch files then?  If you were confident, you could write a short guide that shows them: -

    1. How to map a SharePoint library to a drive
    2. How to open command prompt and change directory to the mapped drive
    3. using the dir /s /b > print.txt

    Viola.

    Assuming that they don't struggle with copy and paste, that should get them started.

    • Marked as answer by Carltonw1 Thursday, September 19, 2013 3:25 PM
    Thursday, September 19, 2013 2:29 PM
  • Steven,

    I didn't think about mapping the doc libraries as a drive. That works perfectly. thanks.

    Thursday, September 19, 2013 3:24 PM