Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Triggers
  • Resources
  • ABOUT ME
  • Get help with your flow
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.

4 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
  2. mechille says:
    September 13, 2022 at 8:13 am

    hi Tom,

    I’m keeping my monthly file in a Sharepoint folder. Every month, I’m adding a File with a file name format of ReviewBSR . Now I want to do conditional trigger that will only trigger the flow whenever I’m creating new files in this folder with a file name that starts with ReviewBSR

    Reply
    1. Tom says:
      September 18, 2022 at 7:13 pm

      Hello Mechille,
      you can combine the action settings (it has a possibility to select which folder it should check) with a trigger condition @startsWith(…) (instead @endsWith from the article).

      Reply

Leave a Reply Cancel reply

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

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


There's also the HTTP requests to SharePoint cheat sheet to help you overcome limitations of some standard actions!

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.

  • How to find Excel rows missing in SharePoint list (Power Automate)March 29, 2023
  • Check whether user exists in AAD with Power AutomateMarch 26, 2023
  • How to highlight whole SharePoint row based on calculated dateMarch 22, 2023
  • Why is your Power Automate flow running so slow?March 19, 2023
  • How to add multiple links to the Power Automate approval taskMarch 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes