Last week, while working on a flow, I encountered a situation where I needed to check if a filename contained a specific keyword before proceeding with further actions. This is a common requirement when managing documents in SharePoint, OneDrive, or email attachments.
In this tutorial, I will show you how to use Power Automate to check if a filename contains a specific word and take action based on it. You will learn how to move files to a particular folder if their names include specific keywords and how to send email notifications to the right team. I will also cover using trigger conditions to make your flow more efficient.
Check If the Filename Contains in Power Automate
Suppose you have a SharePoint document library where invoices are uploaded. You want to automate a process where Power Automate checks if the uploaded file contains the word “Invoice” in its filename. If it does, the file is moved to an “Invoices” folder; otherwise, it remains in the root library.
For this example, I created a SharePoint Document library called Finance Records and an Invoices folder inside it.

Now follow the below steps:
1. Go to Power Automate, create an Automated Cloud Flow, and set the trigger for when a file is created (properties only) from the SharePoint connector.
- Site Address: Select your SharePoint site containing the Finance Records library.
- Library Name: Choose Finance Records.

2. Add the condition action and set the values such as:
@{triggerBody()?['{Name}']} Is equal to Invoice

3. In this true section add a Move file action and provide the below parameters:
- Current Site Address: Select or enter the SharePoint Site URL where the file is located.
- File to Move: Use the “Identifier” from the trigger (dynamic content) to specify the file to be moved.
- Destination Site Address: Select the same SharePoint site or another site where you want to move the file.
- Destination Folder: Enter or browse the folder path where the file should be moved.
- If Another File is Already There: Choose an option:
- Fail this action: Stops the flow if a file with the same name exists.
- Move with a new name: Renames the file to avoid repetition.
- Replace: Overwrites the existing file with the new one.

Now, click Save and run the flow manually. Then go to the SharePoint Document library, add one file whose name contains Invoice.

After the flow runs successfully, go to the SharePoint document library. You will see that the file has been moved to the ‘Invoices’ folder.

Trigger Power Automate Flow if the Filename Contains Specific Name
Here, I will consider the same example as above. Currently, our flow runs every time a file is uploaded, checking if the filename contains a specific word. However, this causes the flow to run unnecessarily, even when the filename does not match.
Now, I want the flow to only trigger when the filename contains the specified word rather than running and checking inside the flow.
To do this, follow the below steps: