cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Momo
Frequent Visitor

Use a flow to mass delete documents on sharepoint

Hello I'm new to using flow,

 

I'm trying to clean up my sharepoint by deleting all documents older then 8 years. However there is a limitation of 100 actions that my flow can do and I'm running into the problem that the first 100 actions are always the same document, which are not older than 8 years... The amount of documents are equal to 25000+ documents...

 

My question: 1. Is it possible to use/make some kind of filter on the get file properties, so that it retrieves files based on modified data? so that my flow will always use the oldest documents in its actions?

2. Is it possible to also filter out the maps from the actions, so that it will only be documents?

3. Is it possible to clean up the documents using Excel? It is possible to receive an overview of the documents in excel... Managing Sharepoint through Excel would be lovely.

 

thanks in advance!

 

image.pngimage.png

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Use a flow to mass delete documents on sharepoint

Hi @Momo,

 

Do you want to delete only files that haven’t been modified more than 8 years?

Please check the following flow for a reference.

For testing, trigger the flow by a Button.

Add the action Get past time, Time unit set as Year, and Interval as 8.

Add action Get files (properties only), input the following code in the Filter query field:

Modified lt ‘formatDateTime(body('Get_past_time'),'yyyy-MM-dd')’

Note: Please surround the function with a single quote in the Filter query box.

Add a Condition to check if it is a folder or not with the following code:

@equals(items('Apply_to_each')?['{IsFolder}'], bool('false'))

Under if yes branch, add the action Delete file, choose dynamic content Identifier from the action Get files.

1.PNG

By the way, I am not sure with “clean up the document using Excel”, could you share more clarification on it? 

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
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

3 REPLIES 3
Community Support
Community Support

Re: Use a flow to mass delete documents on sharepoint

Hi @Momo,

 

Do you want to delete only files that haven’t been modified more than 8 years?

Please check the following flow for a reference.

For testing, trigger the flow by a Button.

Add the action Get past time, Time unit set as Year, and Interval as 8.

Add action Get files (properties only), input the following code in the Filter query field:

Modified lt ‘formatDateTime(body('Get_past_time'),'yyyy-MM-dd')’

Note: Please surround the function with a single quote in the Filter query box.

Add a Condition to check if it is a folder or not with the following code:

@equals(items('Apply_to_each')?['{IsFolder}'], bool('false'))

Under if yes branch, add the action Delete file, choose dynamic content Identifier from the action Get files.

1.PNG

By the way, I am not sure with “clean up the document using Excel”, could you share more clarification on it? 

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
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

Momo
Frequent Visitor

Re: Use a flow to mass delete documents on sharepoint

Hi @v-yamao-msft,

 

It doesn't really give me the results I was looking for... Is it possible to specify in the action "Get past time" to define an interval, which can be used in the get past files action? So that would be Get past time: >8 Years or Between 8 and 26 years (Thats how old the documents are...)

 

And another problem of mine is that that the flow can only look at 100 documents during a run. In my case, these 100 documents are always folders, which result in the flow not deleting anything. A solution to this might be the "order by" option within the "Get files" action. However, I do not know the syntax for order by modified date latest to new and IsFolder no to yes (or something similar). 

 

Any Ideas?

 

And what I actually meant with "clean up the document using Excel" was to manage documents on sharepoint using Excel. But I dont think that it is possible yet. I tried to export file of sharepoint documents (identifier) into excel and delete the documents on sharepoint using the identifier of the file from excel. But it doesn't work for me. 

Momo
Frequent Visitor

Re: Use a flow to mass delete documents on sharepoint

@v-yamao-msft,

 

I didn't know that "Modified lt" meant Modified less than. 1 less problem 🙂

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Users online (6,605)