Showing results for 
Search instead for 
Did you mean: 
Not applicable

OneDrive for Business - Delete files in folder if they are more than 50

I am currently using the following Powershell script:
dir "PATH" | ? {!$_.psiscontainer} | sort LastWriteTime -desc | select -skip(50) | del

The script makes sure that I keep the newest 50 files in one folder. As soon as there are more than 50 files, the oldest ones should be deleted.


How can I implement this in Microsoft Flow? Can I also use Powershell commands in Flow?




Solution Sage
Solution Sage

Hi @Anonymous ,

It seems that you would like to keep the newest 50 files in one folder. And delete the older ones.

I am afraid that there is no way to achieve your needs in Microsoft Flow currently.

There is no function to sort the files by created time in the flow.

Here is a similar idea with your case, you can vote the idea here:

Best Regards,

Community Support Team _ Zhongys

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

Helpful resources

Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (41,227)