Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
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.

  • 72Zib Profile Picture
    68 on at
    Re: Keep limited number of files

    Thanks for your help. This works 🙂

    Z

  • Verified answer
    Expiscornovus Profile Picture
    31,635 Most Valuable Professional on at
    Re: Keep limited number of files

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow