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

Flow fails on condition 'file contents' contains

I am trying to create a flow that triggers when a file is created in a specified folder in OneDrive for Business. The folder will contain searchable PDFs. I want to copy or move the file to a specified folder if it contains a specific term. When I manually search the sale OneDrive folder for the same term the search returns the correct PDF. However the logic fails as a Flow.


I have created a condition on the object 'File Contents', using the relationship 'Contains', and various values, which always resolves to 'No'. I've attached to images and for this example I used 'date' for the value. I've tried other values to no avail -- in each case I am just looking for a string, not a field.


I can't figure out what is incorrect. Does the string need to be in quotes? Is it case sensitive? Is this not the correct way to search within a file for a specific string?






Level: Powered On

Re: Flow fails on condition 'file contents' contains

Can somebody please tell me if a flow can search the contents of pdf files in OneDrive for a particular string?

Community Support Team
Community Support Team

Re: Flow fails on condition 'file contents' contains

Hi danceplus,


I have just tested with a similar flow and I got the same result.


My flow is like below. And I added quotation marks just in case this is the issue:



I have multiple "test" strings in a Word document and I got the below result:



Tested with PDF file ended up with the same result.


It seems that file content cannot be used to search strings inside the file. 


I suggest that you can post this as an idea to the Flow Idea forum so that it could be considered in future release:



Mona Li



Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

Re: Flow fails on condition 'file contents' contains

I appreciate your thoughts on this. What is 'file contents' for then? I don't understand why the same search parameters return the correct file in OneDrive search, but can't be used as a criteria in Flow?

Level: Powered On

Re: Flow fails on condition 'file contents' contains

I was able to get this working by putting the file content inside a string. 


My Flow steps are as follows:


1) When a file is modified

2) Get file content

3) Condition


string(body('Get_file_content')) contains TextYouAreLookingFor   
In this case I'm looking through a text file to see if it contains "ExecuteBackground Error:", but you don't need to include quotes for it to work.
Annotation 2019-02-26 115808.jpg
Annotation 2019-02-26 120203.jpg
4) Send me an email if True
Level: Powered On

Re: Flow fails on condition 'file contents' contains

I can only get this working with TXT file, but not with any other files.

Helpful resources


Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!


Microsoft Learn

Learn how to build the business apps that you need.


Power Platform World Tour

Find out where you can attend!


Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,831)