cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Sharepoint filter by file type/extension

Hi,

I'm trying to create a flow to get only some files.

How can I filter by docx, doc, xls, xlsx, ppt, pptx?

Thanks.

3 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Sharepoint filter by file type/extension

Hi @PedroRibeiro,

 

You could get all files information first by using Get files(properties only).

Then use Filter array to filter files, if the file name with the extension ends with the expected file format.

Use endswith() function to make a decision.

Formula reference:

 

@or(endswith(item()?['{FilenameWithExtension}'], '.docx'),endswith(item()?['{FilenameWithExtension}'], '.doc'),endswith(item()?['{FilenameWithExtension}'], '.xls'),endswith(item()?['{FilenameWithExtension}'], '.xlsx'),endswith(item()?['{FilenameWithExtension}'], '.ppt'),endswith(item()?['{FilenameWithExtension}'], '.pptx'))

Image reference:

30.PNG

Please take a try.

 

Best Regards,

Barry

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Helper V
Helper V

Re: Sharepoint filter by file type/extension

Hi!

 

There is a better and more effecient way to do this. Filtering result array is time consuming for thouthands of documents.

 

Just use this oData filter under Advanced section of the "Get files" action:

File_x0020_Type eq 'xls'

 

You can find example of usage in this article.

 

This approach is better because it returns only required files.

 

View solution in original post

Highlighted
Regular Visitor

Re: Sharepoint filter by file type/extension

This should work for you:

File_x0020_Type eq 'xls' or File_x0020_Type eq 'doc' or File_x0020_Type eq 'ppt'

 

I didn't test it.

View solution in original post

6 REPLIES 6
Highlighted
Community Support
Community Support

Re: Sharepoint filter by file type/extension

Hi @PedroRibeiro,

 

You could get all files information first by using Get files(properties only).

Then use Filter array to filter files, if the file name with the extension ends with the expected file format.

Use endswith() function to make a decision.

Formula reference:

 

@or(endswith(item()?['{FilenameWithExtension}'], '.docx'),endswith(item()?['{FilenameWithExtension}'], '.doc'),endswith(item()?['{FilenameWithExtension}'], '.xls'),endswith(item()?['{FilenameWithExtension}'], '.xlsx'),endswith(item()?['{FilenameWithExtension}'], '.ppt'),endswith(item()?['{FilenameWithExtension}'], '.pptx'))

Image reference:

30.PNG

Please take a try.

 

Best Regards,

Barry

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Frequent Visitor

Re: Sharepoint filter by file type/extension

Barry,

It works.

Thank you.

Highlighted
Helper V
Helper V

Re: Sharepoint filter by file type/extension

Hi!

 

There is a better and more effecient way to do this. Filtering result array is time consuming for thouthands of documents.

 

Just use this oData filter under Advanced section of the "Get files" action:

File_x0020_Type eq 'xls'

 

You can find example of usage in this article.

 

This approach is better because it returns only required files.

 

View solution in original post

Highlighted
Frequent Visitor

Re: Sharepoint filter by file type/extension

@anton-khrit 

Yes I noticed that takes too long because we have multiple files.

With your solution, how can I search for xls, doc, ppt in the same filter? It's possible?

Highlighted
Regular Visitor

Re: Sharepoint filter by file type/extension

This should work for you:

File_x0020_Type eq 'xls' or File_x0020_Type eq 'doc' or File_x0020_Type eq 'ppt'

 

I didn't test it.

View solution in original post

Highlighted
Frequent Visitor

Re: Sharepoint filter by file type/extension

@anton-khrit-hq 

Your solution works perfectly, and is faster.

Thank you.

 

How can I run this in a specific folder inside "Shared Documents"?

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (7,403)