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

Community site session details

Session Id : AjwgkshC+vsVgR6U3ktEJt
Power Automate - Using Flows
Unanswered

Automatically delete files (if not used) in Document Library folders 3 months

Like (0) ShareShare
ReportReport
Posted on 15 Sep 2022 23:11:12 by 2

Hi everyone,

 

So What I want to achieve is to create a flow that automatically deletes everything in certain folders on Document Library, only if nobody touched those folders for 3 months. (meaning, if nobody uses files in certain folders for 3 montsh, I want them to be automatically removed from Sharepoint Document Library).

 

Help would be much appreciated!

 

Thank you!

  • Rodrigo Hentz Profile Picture
    on 22 Sep 2022 at 12:15:27
    Re: Automatically delete files (if not used) in Document Library folders 3 months

    HI @Giga how are you? 

     

    @Giga the suggested process for @Sundeep_Malik helped on your scenario?

     

    If so, please, mark the post as answered or if you need more help on it please let us know 🙂

     

    Best regards

     

    Rodrigo Hentz

    Microsoft Power Platform Support Engineer

     

     

  • Sundeep_Malik Profile Picture
    6,482 on 18 Sep 2022 at 16:22:22
    Re: Automatically delete files (if not used) in Document Library folders 3 months

    So, I added a new file to a folder. But, its modified on date didnt change. I delete as well as modified the files inside it. But the date didnt change for the folder. Only the date changed for the folder, if I renamed the folder. So, I dont think your problem will be able to solve in power automate.

     

    Instead you can try my 1st technique only to delete all the files which were not modified in the last 90 days. And in the identifier just pass the ID field you are getting from get files(properties only).

     

    You can try yourself the folder thing.

     

    I hope this helps.

  • Sundeep_Malik Profile Picture
    6,482 on 18 Sep 2022 at 16:16:53
    Automatically delete files (if not used) in Document Library folders 3 months

    Hey @Giga

     

    So, I have come up with another technique for you. But you can only delete all the files from the folder, not the folder because there is no option to delete a folder.

     

    First use list folder. After this use action get folder metadata and add the id you are getting from above. This will automatically create an apply to each loop. Then use a compose statement to store the modified on field.

     

    Sundeep_Malik_0-1663517489314.png

     

     

    After this use condition and add outputs of above compose and check if its less than the currentdate-90. If yes, use get files(properties only) and after that use delete file option.

     

    Sundeep_Malik_0-1663517692670.png

    But But But, read my next comment before using this.

  • Giga Profile Picture
    2 on 18 Sep 2022 at 15:33:45
    Re: Automatically delete files (if not used) in Document Library folders 3 months

    Hi @Sundeep_Malik ,

    Thank you very much for your response. 

     

    I started building the workflow based on your suggestion, but in a "Delete file/File Identifier" field, it asks me to specify a file that will be deleted. This is not what I want, what I want is to delete everything in the folder/directory that I have specified, if the uploaded content won't be used for more than 3 months.


    select a file.png

     

    Best regards,

    Giga

  • Sundeep_Malik Profile Picture
    6,482 on 16 Sep 2022 at 02:24:52
    Re: Automatically delete files (if not used) in Document Library folders 3 months

    Hey @Giga 

     

    You can use the Action get files(properties only).

    After this use Apply to each and pass value field that you got from above.

    After this use Modified field in a condition and put it less than than the date utcNow-90 days.

    And if yes, just use action delete file.

    Condition add days formula: addDays(utcNow(),-90)

     

    Sundeep_Malik_0-1663294990020.png

    I hope this helps.

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Featured topics

Restore a deleted flow
Loading complete