cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GeekAlf_Pro
Resolver I
Resolver I

Sharepoint Teams delete folders and files based on a date

Hi there,

 

i have a sharepoint Teams subfolder

i want to create a trigger that delete folders and files within that are older than 2 years.

i don't know if it's possible (it seems see here)

but i don't see in powerautomate how to trigger/automate it.

 

thanks for your advices

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Super User
Super User

Hi @GeekAlf_Pro 

 

Sorry about that.  I think I can see the problem from testing at my end and I hope that this makes sense with you.  It would seem like the error you are seeing is to do with the action not being able to delete the folder.  We are trying to delete files?

 

I decided to insert an array filter (after get files properties only) which will only return files and then pass that to the apply to each.  See below:

 

DamoBird365_0-1615915620986.png

 

Let me know if that works for you and if it makes sense of course.

 

Damien

View solution in original post

11 REPLIES 11
DamoBird365
Super User
Super User

Hi @GeekAlf_Pro 

 

Your trigger could be scheduled - i.e. once a week on a Sunday.

 

DamoBird365_0-1615904543018.png

And then apply a filter on get files using the past time created above

 

DamoBird365_2-1615904657806.png

Apply to each on the results from get files and delete those files.

 

As always, please test.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien

Hello @DamoBird365 

thanks a lot, i managed to create a recurrence flow.

but i dont understand why, despiste the flow deleted the files, it finish with an error.

it is because i need to specify to ignore folder ?

GeekAlf_Pro
Resolver I
Resolver I

2021-03-16 17_30_25-Historique des exécutions _ Power Automate.png

DamoBird365
Super User
Super User

Hi @GeekAlf_Pro 

 

Can you take a look at the history and try to find where it has failed. If it’s during the apply to each, navigate through each run to see where and why it failed. Can you then copy or screenshot the error?

 

Damien

DamoBird365
Super User
Super User

Can you expand that action and screenshot? Was it all 3 that failed within the apply to each or just 1 of 3? You can navigate between each run to see.
GeekAlf_Pro
Resolver I
Resolver I

here is the message error : 

 

Le fichier /sites/TeamTIGRE-GestionContrevenants/Shared Documents/Gestion Contrevenants n'existe pas.
clientRequestId: 20c68c85-6208-4911-95b2-e663369ea507
serviceRequestId: aee1b49f-707e-2000-abb6-a284cc4fb1f6

 

and a screenshot of the 3 errors, each time it refers to the name folder : 

2021-03-16 17_47_54-Historique des exécutions _ Power Automate.png

 


@GeekAlf_Pro wrote:

Hi there,

 

i have a sharepoint Teams subfolder

i want to create a trigger that delete folders and files within that are older than 2 years.

i don't know if it's possible (it seems see here)

but i don't see in powerautomate how to trigger/automate it.

 

thanks for your advices



@GeekAlf_Pro wrote:

Hi there,

 

i have a sharepoint Teams subfolder

i want to create a trigger that delete folders and files within that are older than 2 years.

i don't know if it's possible (it seems see here)

but i don't see in powerautomate how to trigger/automate it.

 

thanks for your advices


 

DamoBird365
Super User
Super User

I think you need to check the dynamic field used for the file identifier. I think you have the wrong one chosen. It’s reporting file not found?

yes that's it, but i dont know how to configure the dynamic field.

especially due to the french translate !

here is choices availables 

 

2021-03-16 18_03_12-Modifier votre flux _ Power Automate.png

Hi @GeekAlf_Pro 

 

I'm looking into this as I get the same, please bear with me....

 

DamoBird365
Super User
Super User

Hi @GeekAlf_Pro 

 

Sorry about that.  I think I can see the problem from testing at my end and I hope that this makes sense with you.  It would seem like the error you are seeing is to do with the action not being able to delete the folder.  We are trying to delete files?

 

I decided to insert an array filter (after get files properties only) which will only return files and then pass that to the apply to each.  See below:

 

DamoBird365_0-1615915620986.png

 

Let me know if that works for you and if it makes sense of course.

 

Damien

View solution in original post

hi @DamoBird365 

 

it works fine !

 

thanks a lot for the time 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,150)