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 / Automate Deletion of F...
Power Automate
Unanswered

Automate Deletion of Files Inside Subfolders

(0) ShareShare
ReportReport
Posted on by 2

Hello everyone,

I have a folder structure set up in SharePoint as follows:

Documents > General > testing > A

Inside the A folder, there are individual folders for all people whose names start with the letter A. Each of these individual folders needs to be automatically deleted every 3 months using Power Automate, regardless of the file types inside.

The testing folder contains similar subfolders named from A to Z.

Important: The subfolders A to Z themselves need to be preserved and only the files inside the individual folders within each letter folder should be deleted every 3 months.

Could someone please guide me on how to create a Power Automate flow to delete all files inside the individual folders under each letter folder (A to Z) on a recurring 3-month schedule, while keeping the folder structure intact?

Thanks in advance for your help!

Categories:
I have the same question (0)
  • Tomac Profile Picture
    4,061 Moderator on at
    Hi, to quickly clarify, the A through Z folders should remain intact but the user name folders within should be deleted along with files, correct?
  • David_MA Profile Picture
    14,499 Super User 2026 Season 1 on at
    You would do this:
    1. Create a scheduled flow that runs every day.
    2. Add a Get files (properties only)
      1. Point it to your document library.
      2. In advanced settings, choose folder "A".
      3. Set include nested items to yes.
      4. Add a filter query where the created date is less than or equal current date minus three months: Created le '@{addToTime(utcNow(), 3, 'Month')}'
    3. Add a condition to check if any files were found.
    4. One the yes side of the condition, add an apply to each action.
    5. In the apply to each action, add a delete file action.
     
    This will handle deleting the files, although it may need to be tweaked as I am not sure I completely understand your requirements or folder structure.
     
    I also am not sure how to handle the scenario you've described regarding deleting the folders. Someone else will need to provide a solution for that. If this were something I were doing, I would most likely look into Purview retention labels. Something like what is outlined here: Setting up a retention policy separately for a folder or document - Microsoft Community, which seems to fit your use case.
  • AbrahamM Profile Picture
    2 on at
    Thanks David and Tomac, just to clarify the A through Z folders should remain intact, and so should the user name folders within them. Only the files inside each user folder should be deleted.
  • David_MA Profile Picture
    14,499 Super User 2026 Season 1 on at
    So, you are saying all folders remain intact and none need to be deleted? If so, what I outlined below should work. Just be sure to choose the correct folder level where you want to begin the deletion of files. If there are more than 100 files that need to be deleted with every run, you will need to enable paging on the Get files action and set it to how many files would need to be deleted.
     
    For example:
     
    Also, if there are or will be more than 5,000 files in this document library, be sure to index the Created date or this will not work correctly.
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 959

#2
Valantis Profile Picture

Valantis 872

#3
Haque Profile Picture

Haque 589

Last 30 days Overall leaderboard