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 / Power Automate Desktop...
Power Automate
Answered

Power Automate Desktop - Deleting files with conditions

(0) ShareShare
ReportReport
Posted on by 6

Hi,

I was actually trying to look out for a work around where we can delete files based on a condition. To be precise, I want to have the latest 5 files based on the creation time and want to delete the rest of the files from the folder, can someone help me with it? It would be great if someone can share me with the similar answers or guides related to the question

 

It is to be there in power automate desktop and not on the cloud flow.

I have the same question (0)
  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    Get Files to %Files% sort by Last modified

     

    Loop starting at 1 ending at %Files.Count - 1% increment 1

        If %LoopIndex% > 4,

            Delete %Files[LoopIndex]%

        End (If)

    End (Loop)

  • achez15 Profile Picture
    2 on at

    Hi everyone,

    I have a similar question that I was hoping someone knew how to do.

     

    I would like to delete all files that contain specific text within their string from all subsites of a specific hub site.  The files in question are all named the following (XXXXX  and YYYY are unique within each subsite).  XXXXX_YYYY-Image-Workbook 

     

    Therefore I would like to create a power procedure to go through document library of each subsite and delete files that contain "Image-Workbook" within the string.

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 276 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard