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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Keep limited number of...
Power Automate
Answered

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,871 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 378

#2
Valantis Profile Picture

Valantis 329

#3
David_MA Profile Picture

David_MA 283 Super User 2026 Season 1

Last 30 days Overall leaderboard