Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Template
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

How to get files from specific SharePoint folders in Power Automate

Posted on September 22, 2021September 26, 2021 by Tom

“I have a SharePoint library with multiple parent folders, each with the same folder inside, how can I get all the files in these subfolders in a single Power Automate flow?”


The standard Power Automate action ‘Get files (properties only)’ allows you to limit the entries to a folder. But it’s just one folder. That’s fine in most situations, but what if you need to search in multiple folders? If your folder structure is more complex, e.g. multiple folders, each with their own ‘Draft’ subfolder? And you want all the documents from that subfolder?

Power Automate files SharePoint folders

The ‘Get files…’ action itself won’t help you in such situation. What you’ll need is to use a Filter Query.

Check the file path

One of the available file properties is the path to the file. If you used that in the Filter Query, you could search only for files that contain the specific folder in their path.

Unfortunately, you can’t use the ‘{FullPath}’ property in the Filter Query. But as already explained in the post on filtering by file name, you can use a similar path. The server relative path represented by the property with internal name ‘FileRef’.

Combine it with the substringof(…) filter in the Filter Query, and check if the path contains the specific folder, e.g.

substringof('Draft', FileRef)

Such ‘Get files…’ action will return only files with ‘Draft’ in their path = files in the ‘Draft’ folder.

Skip the folders themselves

Since the ‘Get files…’ will return everything with the folder name in the path, it’ll return the folder(s) too. Processing a folder could cause errors in your flow as it’s not an actual file. It doesn’t have content nor properties, and it’s better to ignore them. Do that by using the other “hidden” file property: FileLeafRef – the file name with extension. As the folder doesn’t have any extension, it’ll contain just the folder name.

The file path must contain ‘Draft’ (the folder name), but at the same time the file can’t be called ‘Draft’. Add the second filter to the Filter Query with the AND operator.

substringof('Draft', FileRef) and FileLeafRef ne 'Draft'
Power Automate files SharePoint folders

The result will be only the files in the ‘Draft’ folders.

Summary

Even if Power Automate doesn’t allow you to get files from multiple SharePoint folders directly, you can still filter them out with a Filter Query. A Filter Query that looks simple, but there’re some advanced concepts behind. There’s the substring(…) filter, where I often enter the parameters in the wrong order. The FileRef and FileLeafRef properties, not shown anywhere in the file properties, but necessary to work with files. And the combination of multiple filters in a single Filter Query.


πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

2 thoughts on “How to get files from specific SharePoint folders in Power Automate”

  1. Sotiris Georgakakos says:
    November 26, 2023 at 11:25 am

    Thank you. This substringof function helped me a lot!

    Reply
  2. It Support says:
    June 20, 2024 at 9:39 am

    Hello There,

    Could you please help me with how to exclude a specific folder (with files) to be copied?

    example:
    General > Main Folder
    Folder 1 > Sub folder
    Folder 2 > Sub folder >> I want this entire folder not to be copied in my power automate flow.

    Thank you in advance.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Still exchanging emails to get things approved?

Use the Approval Process Template and the Task Delegation App to skip the hard part and deploy an automated, fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundleβ€”everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes