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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to create a flow t...
Power Automate
Unanswered

How to create a flow to delete files in SharePoint

(0) ShareShare
ReportReport
Posted on by 21

Hello,

 

I'm looking to create a flow which would automatically delete files from a folder in a SharePoint library.

I would like to delete all files older than 7 days that are in a specific folder in my library with this rule.

 

Could you guide me through creating this flow?

Thanks. Baptiste.

 

 

Categories:
I have the same question (0)
  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Baptiste_k97 

    Please follow below steps :

    1. you need a scheduled recurring flow to run daily 

     

    2. Use Get Past time to get the time in the past by 7 days

     

    3. Use the Get Files Action to get the files you want to delete from the folder

     

    4. Expression on Filter Query Right hand side

    formatDateTime(body('Get_past_time'),'yyy-MM-dd')

    Note: Do not forget single quotes between the format expression

    Mira_Ghaly_0-1621070513082.png

    5. Apply to Each and Delete files

    Mira_Ghaly_1-1621070714320.png

     

     

  • Baptiste_k97 Profile Picture
    21 on at

    <p>Hello,</p>
    <p>Thanks for your help. I'm having a problem in step 3 that makes my flux unusable.</p>
    <p>How do I write the expression "Created It" before the filter query ?</p>
    <p>&nbsp;</p>
    <p><img src="https://nsa40.casimages.com/img/2021/05/15/210515060151323418.png" border="0" alt="" /></p>
    <p>&nbsp;</p>
    <p>I tried to write it by hand, but I get the error below when I run the stream.</p>
    <li-code lang="markup">L'expression &laquo; Created It '2021-05-14' &raquo; n'est pas valide. Creating query failed.
    clientRequestId: 7dd9422a-1f96-48ad-9d39-a73d6e315f4a
    serviceRequestId: 7dd9422a-1f96-48ad-9d39-a73d6e315f4a</li-code>
    <p>&nbsp;</p>
    <p><img src="https://nsa40.casimages.com/img/2021/05/15/210515060009285867.png" border="0" alt="" /></p>
    <p>&nbsp;</p>
    <p>Thank you in advance for your reply.</p>
    <p>Regards. Baptiste</p>

  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Baptiste_k97

    Is your column name in french in sharepoint?

    Can you please add screenshot of your flow?

     

  • Baptiste_k97 Profile Picture
    21 on at

    Yes @Mira_Ghaly my column name is in French in SharePoint.

    Baptiste_k97_0-1621141394914.png

     

    My flow :

    Baptiste_k97_3-1621141901080.png

     

    Baptiste_k97_2-1621141816865.png

     

  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Baptiste_k97 

    Can you use the French name in place of Created?

     

  • Baptiste_k97 Profile Picture
    21 on at

    Hello,

    I tried with the French name of my column but the result remains the same.

    Baptiste_k97_0-1621181221360.png

     

    Here is the column in question:

    Baptiste_k97_1-1621181298887.png

     

    Details of the error :

    Baptiste_k97_2-1621181387329.png

     

  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Baptiste_k97 

    it is missing the Cree lt 'format...'

     

     

  • Baptiste_k97 Profile Picture
    21 on at

    @Mira_GhalyI still have the same error.

    In "Filter query" I put the following expression :

     

    Cree it 'format...'

    formatDateTime(body('Obtenir_l''heure_passée'),'yyy-MM-dd')

     

    Baptiste_k97_0-1621234269986.png

     

  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Baptiste_k97

    Please use

    Fieldnameinfrench lt

     

    lt for less than

  • Baptiste_k97 Profile Picture
    21 on at

    Hello @Mira_Ghaly 

    I tried all the possibilities with the french name of my SharePoint column :

    • Créé + it + '...'
    • Modifié + it + '...'
    • Créé + '...'
    • Modifié + '...'

     

    I still have this same error telling me that the "query filter" is invalid.

    Baptiste_k97_0-1621262264253.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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard