cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
frixel
Post Prodigy
Post Prodigy

Delete files in OneDrive older than 60 day`s

I try to make a flow for Delete files in OneDrive older than 60 day`s with this example.

 

But for this point:

  3-1. Action: Data Operations - Compose ( Inputs = "@div(sub(ticks(utcnow()), ticks(item()?['LastModified'])), 864000000000)" )

i can`t put it in the expression box, it gives a error.

 

Is there an other example to make a flow for Delete files in OneDrive older than xx day`s?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @frixel ,

 

Please use Compose output Last modified and Is folder.

45.PNG

Please show the details of your Flow configuration.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

14 REPLIES 14
v-bacao-msft
Community Support
Community Support

Hi @frixel ,

 

You can also try to filter the file using formatDateTime() function and addDays() function.

Expression reference:

formatDateTime(item()['LastModified'],'yyyy-MM-dd')
addDays(utcNow(),-10,'yyyy-MM-dd')

Image reference:

35.PNG

Please take a try.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-bacao-msft :

I believe that "false" in your condition must be entered in the expression window.  The screen shot looks like is was entered just as text.  Am I correct?

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Hi @ScottShearer ,

 

Thank you for your reminder, but I have tested it and found that using false is still work.

Image reference:

39.PNG40.PNG

The current item is a file, so the result here is true.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

In both cases (false as text or expression) the flow does not work and the file`s from 3 days ago are not deleted.

 

flow4.png

Hi @frixel ,

 

Please use Compose output Last modified and Is folder.

45.PNG

Please show the details of your Flow configuration.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

When i do this al the files wil be deleted Smiley Mad

 

flow5.png

What happened, it should only delete the eligible files according to the conditions you set.

 

 

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ahh,sorry. I forget to "update" the  addDays(utcNow) expression Man Happy

Now it works fine.

Can I ask one more question?

If I want to receive 1 mail when files have been deleted, how do I set it?

If I do it like the below, flow sent an email for each deleted file.(it would be even better if flow counts how many files have been deleted.)

 

flow7.png

 

 

Hi @frixel ,

 

You can initialize an array to store information about the filtered files.

Use Length() function to calculate the number of files, or you could create an HTML table to display file information.

Image reference:

49.PNG50.PNG

 

Please take a try.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

flow8.png

51.PNG

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-bacao-msft 

See below. Mail is send but files are not deleted.

 

 

 

 

 

flow10.pngflow11.png

Hi @v-bacao-msft  @ScottShearer 

 

If i set that files older than 3 day`s must be beleted is delets file`s from 01-05-2019 -02-05-2019 and 03-05-2019

 

flow12.pngflow13.png

 

flow14.png

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,430)