cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PedroRibeiro
Level: Powered On

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
Community Support Team
Community Support Team

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

Super User
Super User

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
anton-khrit-hq
Level: Powered On

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
Community Support Team
Community Support Team

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

PedroRibeiro
Level: Powered On

Re: Sharepoint filter by file type/extension

Barry,

It works.

Thank you.

Super User
Super User

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

PedroRibeiro
Level: Powered On

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
anton-khrit-hq
Level: Powered On

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

PedroRibeiro
Level: Powered On

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 Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

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!

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (5,636)