cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

I want Flow to delete all file in one folder in a sharepoint library

HI

 

my situation is that i want delete all the file that are in a folder, that folder is in a library.

 

we receive up to 13 file in a day by Email. I've create a flow that transfert all those file from outlook to a sharepoint in a library.

 

I may receive the last file of the day an hours before the day finish, but i still want that file to be deleted at the end of the day so the next day we can start all over.

 

so this flow has to be execute at the same time each day so i know i have to first put the recurrence but after that i don't know how to get all those file and deleted those file at the time of the execution of the flow

 

I don't want to delete the folder because the same folder will be use the next day

 

is it possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: I want Flow to delete all file in one folder in a sharepoint library

Hi @Anonymous,

 

Does your folder of SharePoint library includes sub-folders?

 

I assume that your SharePoint library folder doesn't include sub-folders, I have made a test on my side and please take a try with the following workaround:

  • Add a Recurrence trigger, Interval set to 1 and Frequency set to Day. At these hours set to 23 and At these minutes set to 59.
  • Add a "Get files (properties only)" action. specify Site Address and Library Name (Library Name field set to Reporting).
  • Add a "Filter array" action, From set to output of "Get files (properties only)" action, click "Edit in advanced mode", type the following formula:
@equals(item()?['{Path}'], 'Reporting/FlowTest/')

Note: The Reporting represents SharePoint library name, the FlowTest represents the folder name in the SharePoint library.

 

  • Add a "Apply to each" action, input parameter set to output of "Filter array" action. Within "Apply to each", add a "Delete file" action, specify Site Address, File Identifier field set to following formula:
item()?['{Identifier}']

Image reference:14.JPG

The flow works successfully as below:15.JPG

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Community Support Team
Community Support Team

Re: I want Flow to delete all file in one folder in a sharepoint library

Hi @Anonymous,

 

Does your folder of SharePoint library includes sub-folders?

 

I assume that your SharePoint library folder doesn't include sub-folders, I have made a test on my side and please take a try with the following workaround:

  • Add a Recurrence trigger, Interval set to 1 and Frequency set to Day. At these hours set to 23 and At these minutes set to 59.
  • Add a "Get files (properties only)" action. specify Site Address and Library Name (Library Name field set to Reporting).
  • Add a "Filter array" action, From set to output of "Get files (properties only)" action, click "Edit in advanced mode", type the following formula:
@equals(item()?['{Path}'], 'Reporting/FlowTest/')

Note: The Reporting represents SharePoint library name, the FlowTest represents the folder name in the SharePoint library.

 

  • Add a "Apply to each" action, input parameter set to output of "Filter array" action. Within "Apply to each", add a "Delete file" action, specify Site Address, File Identifier field set to following formula:
item()?['{Identifier}']

Image reference:14.JPG

The flow works successfully as below:15.JPG

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Re: I want Flow to delete all file in one folder in a sharepoint library

Hi @v-xida-msft,

 

yes the sharepoint has a sub folder, all the file we receive are send in the sub-folder of the library.

 

does this solution that you just gave will work even in a sub folder?

 

Thank you so much for the info if i didn't had a sub folder

Community Support Team
Community Support Team

Re: I want Flow to delete all file in one folder in a sharepoint library

Hi @Anonymous,

 

If the folder of your SharePoint library has a sub-folder, I think the solution I provided could also achieve your needs. I assume that the Reporting is your SharePoint library name and the FlowTest is a folder of the Reporting library. In addition, the FlowTest folder has a sub-folder called Subfolder1.

 

Please take a try with the above solution that I provided, within "Filter array" action, click "Edit in advanced mode", modify the formula as below:

@equals(item()?['{Path}'], 'Reporting/FlowTest/Subfolder1')

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: I want Flow to delete all file in one folder in a sharepoint library

Hi @v-xida-msft,

 

I'm sorry for this late respond.

 

the flow that you gave me work perfectly !!

 

Thank you so much.

 

is I have some more question for you is there a way that I can keep contact with you?

jcercal
Level: Power Up

Re: I want Flow to delete all file in one folder in a sharepoint library

Hello,

 

In my case the result of test for "Apply to Each" not work - "the input arrey was empty". Why?

 

 

jcercal
Level: Power Up

Re: I want Flow to delete all file in one folder in a sharepoint library

flow.png

jcercal
Level: Power Up

Re: I want Flow to delete all file in one folder in a sharepoint library

I just made more tests and for path in Filter Array = Departamental/Comum/Teste , it doesnt works, but one leve upper this works 'Departamental/Comum' is this a limitation? Can I work arroud to it?

Helpful resources

Announcements
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (3,531)