cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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?

 

 

2 REPLIES 2
Highlighted
Community Support
Community Support

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:

formatDateTime(utcNow(),'yyyy-MM-dd')

1.PNG2.PNG

 

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.
Highlighted
Frequent Visitor

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

@v-yamao-msft

 

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

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

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

thirdimage

Power Automate Community User Group Member Badge

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

Users online (7,708)