I want to share my Flow for delete files older than 7 day.
Clear old files from my servers.
Old files mean that last update datetime more than 7 days ago.
for keep free storage space in my drive.
1. Trigger: Scedule - Recurrence ( Freaquency = Day, Interval = 1)
2. Action: File Systems - List files in folder ( Folder = <your target folder> )
3. Apply to each
3-1. Action: Data Operations - Compose ( Inputs = "@div(sub(ticks(utcnow()), ticks(item()?['LastModified'])), 864000000000)" )
3-2. Condition: ( Compose - Outputs , is greater than, 7 )
3-2-1. Action: File Systems - Delete file ( File = Path )
3-2-2. Action: Microsoft Teams - Post message ( Message = Delete Name )
Comment 3-1 : Need double quote for Inputs.
Comment 3-1 : Calcurate days from last updated.
Comment 3-2 : Outputs from 3-1 Compose.
Comment 3-2-1 : Path from Step 2 List files in folder.
Comment 3-2-2 : Name from Step 2 List files in folder.
Thanks for sharing.
Please also submit this into Flow template, Which I think should be helpful for the others to use as an example.
Thanks for this. I have a situation where I need to delete all folders within a parent folder on a regular basis. Will this Flow do that, or can you recommend how?
Thank you for posting to the Microsoft Flow Community forums! I see that in one of the above replies you were offered a solution to your issue! If you feel that the reply offered an applicable and satisfactory solution, please click "Accept as Solution" so that other users can find this information and utilize it easily!
Flow Community Manager
I have tried to copy this functionality for items in a Sharepoint list. When I run the flow, it runs into an error during the "Condition" section, as it claims that the Output from the Compose function is a string that can't be compared to the number I have put there.
Is there any reason the Input you create in Compose would produce a String value for a Sharepoint list where it wouldn't for a File? Do I need to do something different for a Sharepoint List item that you are aware of?
We've updated and improved the layout and uploading format of the Power Automate Cookbook!
Fill out a quick form to claim your user group badge now!
We've given our badges an overhaul and also added some brand new ones!
Learn how to build the business apps that you need.
Find out where you can attend!
Watch & learn from the Power Automate Community Video Gallery!