web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Limit the number of fi...
Power Automate
Suggested Answer

Limit the number of files in a sharepoint folder

(1) ShareShare
ReportReport
Posted on by 4
HI everyone
I want to create a flow to export a snapshot data from power bi to sharepoint. I have created the flow to export data and create a new file everytime the flow runs. But I want to limit the number of files to 15. so whenever the count crosses 15, I want to delete the oldest file automatically. How to set up the flow?
Categories:
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    I think a flow such as this can do what you want:
    The expression in the condition is length(outputs('List_folder')?['body']), which is the number of files returned from the list folder action. Point the list folder action to your site and the exact folder where you want to limit the number of files. I only had nine files in this folder, so for demo purposes I used 8 in the condition, but you would use 15.
     
    For the Get files (properties only) action you need to set some parameters:
    Be sure to sort by Created asc (ascending) so the oldest files are listed first. Then limit the count to how many files exceed your limit by using this expression: sub(int(length(outputs('List_folder')?['body'])), 8). You would change 8 to 15.
     
    I think the rest is self-explanatory. The Compose File Returned action I just put both expressions in there to make sure my expressions were correct:
     
     
  • AS-09100553-0 Profile Picture
    4 on at
    What will be the expression for delete action?
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 507 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 267 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard