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 / Keep limited number of...
Power Automate
Unanswered

Keep limited number of files

(0) ShareShare
ReportReport
Posted on by 68

Hi 

Is there a way to keep limited number of files in SharePoint folder? When new file is created in SharePoint from outlook, I would like to set a limit to 30 files so when 31st file would arrive the oldest would need to be deleted.

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @72Zib,

     

    Yes, this would be possible by using a Get files action (order it by ID ascending) and count the length of the output. When this equals 31 you could use the identifier of the first item (since it is ordered ascending by ID) and delete that file.

     

    Below is an example of that approach.

     

    deletefile_limit.png

     

    1. Add a Get Files (properties only action). Configure it to use your specific folder. Make sure you also use the sort ID asc.

     

    getfiles_propertiesonly.png

     

    2. Add a condition with the following expression:

    length(outputs('Get_files_(properties_only)')?['body/value'])

     

    3. Add a delete file action. Use the following expression to delete the first file.

    outputs('Get_files_(properties_only)')?['body/value'][0]['{Identifier}']

     

    condition_lenght31.png

  • 72Zib Profile Picture
    68 on at

    Thanks for your help. This works 🙂

    Z

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard