cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Australia
Helper V
Helper V

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
Super User
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
Super User
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
Super User
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
Super User
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

@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
Super User
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Kudoed Authors
Users online (1,509)