cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Australia
Post Patron
Post Patron

Get all file names from a SharePoint Document Library?

Hi fellow Power Automate veterans,

 

Is there a way I can use Power Automate to extract all file names from a SharePoint Document Library? 

Perhaps like list in cmd where it keeps the folder path that'd be even better.

 

My current library structure is as follows:

 

My Document Library  (500+ files in total)

>

ABC123.xls

ABC224.xls

ABC302.xls

...
   >SubFolder 2021

2021_1.xls

2021_2.xls

...

   >SubFolder 2020

2020_1.xls

2020_2.xls

...

 

 

Many thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Dual Super User
Dual Super User

Hi @Australia,

 

Apologies, forgot to respond to your Path question.

 

Amend the uri to this please (added the FileRef field in the select) to also include the path:

_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef

 

View solution in original post

7 REPLIES 7
Expiscornovus
Dual Super User
Dual Super User

Hi @Australia,

 

You could use a Send an HTTP request action for this and use the REST API to retrieve the items. You can apply a select to retrieve the FileLeafRef (file name).

 

Below is an example of that approach

 

_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef

 

listallfiles_documentlibrary.png

@Expiscornovus  many thanks for the prompt reply!

I am just wondering if this API is free?

How do I save the results as a CSV/Excel file?

Possible to retain the folder name/path if possible?

Expiscornovus
Dual Super User
Dual Super User

Hi @Australia,

 

This is an action from the SharePoint connector (a non-premium one). The REST API is part of the SharePoint Online product, https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoin....

 

So, no additional licensing should be needed to use both.

 

For a CSV you can use the Create CSV table action. Use the body/value output in the From field. You can use this expression for that:

 

 

outputs('Send_an_HTTP_request_to_SharePoint')?['body/value']

 

 

createcsvtable_fileleafref.png

 

Expiscornovus
Dual Super User
Dual Super User

Hi @Australia,

 

Apologies, forgot to respond to your Path question.

 

Amend the uri to this please (added the FileRef field in the select) to also include the path:

_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef

 

@Expiscornovus It works, marvellous! Thank you so much. Your solution helped me tremendously.

Now I need to use Power Automate Desktop to upload these files to a website. Would you be the one to ask, too? IF yes, I can open a new post. 🙂

Expiscornovus
Dual Super User
Dual Super User

Hi @Australia,

 

Great to hear that it works 🙂

 

I could help out with desktop flows. However, there are also a lot of other people who can help you too 😁

 

Just post a new thread in this section:

https://powerusers.microsoft.com/t5/Power-Automate-Desktop/bd-p/MPADesktop

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (3,670)