Share via


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

Question

Wednesday, September 18, 2013 4:28 PM

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?

All replies (7)

Thursday, September 19, 2013 2:29 PM ✅Answered

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.


Wednesday, September 18, 2013 5:37 PM

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:41 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 6:37 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.


Thursday, September 19, 2013 3:24 PM

Steven,

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


Wednesday, February 21, 2018 7:10 PM | 1 vote

Please user the step below;

> Select the folder

> On the top click on Library

> Select Export to Excel

Boome done....


Wednesday, September 19, 2018 9:04 PM

You can get a list of files (with additional information) as an Excel sheet by using DMS-Shuttle for SharePoint. It is a Desktop tool, not a command line application. There is a 15 days trial. Please see this article for details: dms-shuttle.com/documentation/export-file-list-sharepoint-site-excel/