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

Checking if a SharePoint has a file with a certain date in the FileName

I have a SharePoint folder where my team creates and updates a status file every two weeks. Right now I have a Flow setup that automatically copies an empty template and puts the current date on it.


I want to change the flow so that it copies the previous file from two weeks ago so I made a new Flow.


First it does a Sharepoint List Folder on the folder


And then I have an "Apply to Each"

Where it loads SharePoint Body as it was the only option


I do a condition where it compares the SharePoint Name to a GetPastTime Function to see if there is a date in the format. Only it never returns true. I've tried DisplayName, CurrentItem of the Apply to Each, etc but none of them work.


What am I forgetting?



Community Support Team
Community Support Team

Re: Checking if a SharePoint has a file with a certain date in the FileName

Hi @JesseM,


Do you want to copy a previous file that was created two weeks ago?


How is the file named? Is it directly named with the Date? For example, 2018-8-24.


I have made the following test on my side, please take it for a reference.


The file is named with the date, e.g. 2018-8-24. If a file with a name that is two weeks ago, copy and create a new file with the current date as the name in the same folder.


The flow is configured likes below.


The function used in the Condition is:

@contains(formatDateTime(items('Apply_to_each')?['{Name}'], 'yyyy-MM-dd'), formatDateTime(getPastTime(14, 'Day'), 'yyyy-MM-dd'))


In the action Create file, use the current date as the file name, the function is:




Please take a try with it on your side.


Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
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: Checking if a SharePoint has a file with a certain date in the FileName



Yes the filename has the date it in like 2018-10-12 at the start of the filename.


I'm using the SharePoint List Folder though. My Condition looks like this


@contains(items('Apply_to_each_2')?['Name'], getPastTime(11, 'Day', 'yyyy-MM-dd'))


Helpful resources


Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!


New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!


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 Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,194)