Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

Trigger Power Automate flow only on specific file in a library

Posted on March 30, 2022March 30, 2022 by Tom

“I’d like to trigger my Power Automate flow only when a specific file(s) are modified, not for all the files in the library!”


When you build a flow in Power Automate, it’s connected to the whole library. It doesn’t care what file users add or modify, it’ll process all the files in the same way. But sometimes you don’t want to process every file. There could be a change notification only for a single file in the library. Approval process that’s started only for a specific file type. Or a flow based on the file location in a folder structure. In all these situations it’s necessary to somehow recognise the file and process it or not.

Don’t use a ‘Condition’

While the first idea can be to use a ‘Condition’ in the flow, it’s not the right approach. To evaluate a condition the flow would have to trigger. Each trigger will cost you API calls and create an entry in the flow run history, leading to bit of a mess. That’s why you should go one step back, to the trigger.

Power Automate trigger specific file

Use a ‘Trigger Condition’ instead

If you go in the trigger settings, you’ll see a section called ‘Trigger Conditions’.

The trigger conditions setting allows you to add a condition directly in the trigger.

The flow doesn’t have to trigger to evaluate this condition, it’ll check it before that happens. If the condition returns ‘true’, the flow will run. If it returns ‘false’ the flow won’t start.

Therefore, if your goal is to run a flow only for a specific file, you should use a trigger condition. You can run the flow only for a file with an exact name:

@equals(triggerOutputs()?['body/{FilenameWithExtension}'], 'TriggerFile.txt')

It’s possible to run it for files that contain a specific string in the file name:

@contains(triggerOutputs()?['body/{FilenameWithExtension}'], 'TriggerFile')

It can trigger for a specific file type:

@endswith(triggerOutputs()?['body/{FilenameWithExtension}'], '.pdf')

Or run on files in a specific folder:

@contains(triggerOutputs()?['body/{Path}'], '/Review/')

Don’t worry if you don’t know how to create such condition, you can use a workaround with the ‘Filter array’ action to create the right one for your needs.

Enter the condition as the ‘Trigger Condition’ in the trigger action and let your flow run only when it’s needed.

Power Automate trigger specific file

Summary

If you want to trigger your Power Automate flow only on a specific file, you should identify the file right away. That means in the trigger. Instead of running the flow for all the files and deciding in the flow what to do, you can use a trigger condition and run the flow only when necessary.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

2 thoughts on “Trigger Power Automate flow only on specific file in a library”

  1. Thomas says:
    June 10, 2022 at 8:27 pm

    Hi Tom! Great post, this low-code approach is immensely helpful! Would it be possible to use low-code in order to enable the flow to identify specific destination folders based on date?
    i.e. A file that has the date March_2022 in its title to be copied in the relevant destination folder, March 2022 and so on, without having to create multiple flows for each year/month.

    Reply
    1. Tom says:
      June 19, 2022 at 9:38 am

      Hello Thomas,
      you can do that, just split the file name (https://tomriha.com/how-to-split-file-name-for-further-processing-in-power-automate/) and then use the parts of the name to build the destination folder.

      Reply

Leave a Reply Cancel reply

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

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Format results of date calculation in SharePoint columnJune 29, 2022
  • Why is your Power Automate flow creating duplicatesJune 26, 2022
  • How to create a unique identifier in your Power Automate flowJune 22, 2022
  • How to assign custom SharePoint permission level with Power AutomateJune 19, 2022
  • Remove permissions from a specific SharePoint user with Power AutomateJune 15, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme