Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Unanswered

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

(0) ShareShare
ReportReport
Posted on 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 at
    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,480 on at
    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,480 on at
    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 at
    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,480 on at
    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

🌸 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,658 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow