cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
frixel
Level: Powered On

Delete files in OneDrive older than 30 days

i all,

 

I have been busy with this flow before and I thought it was solved.
See here this topic

 

I now have the Flow below, but it keeps throwing files away even though they are less than 30 days old.
The Flow also does not process more than 20 files while there are 100 that can be cleaned up.

 

Flow1.png

 

31 REPLIES 31
Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

Hi @frixel 

 

In the List files in a folder, you can change the settings by enabling pagination and adding a value of your choice over there to get the number of files (Please see the screesnhot below)

 

asds.png

Also, please wrap the date in the ticks() function so that the comparision of the date is done properly. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

Hi @yashag2255 

 

What do you mean with:

please wrap the date in the ticks() function so that the comparision of the date is done properly. 

 

And a error when i changed the pagination.

 

Flow1.png

Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

@frixel 

Can you share a screenshot of what error is coming? You were telling you had about 150 files so you can update the threshold to that number. By wrapping in ticks I meant that in the fomrat date and time function, use ticks(formatdatetime...) (please update the function acoordingly. you just have to add ticks() and ithin the brackets put the already available expression) E.g., ticks(formatDateTime(item()['LastModified'],'yyyy-MM-dd')) and do the same for the add days function. 

 

Hope this Helps!

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

Hi @yashag2255 

 

Thanks, i changed the "ticks"☺

But i have this error when i changed the pagination.

Flow1.png

Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

@frixel 

 

Can you try reverting the pagination change and check if you continue to get the error?

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

Hi @yashag2255 

 

I changed it to differents numbers but i get always the error.

 

Flow1.png

Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

Can you disable the pagination and run and check if you get the same error?

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

hi @yashag2255 

 

Yes, then is there no error but only 20 files will be deleted and then the flow stops. 😞

 

Flow1.png

Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

Hi @frixel 

 

I just made a test at my end and unfortunately, right now the max number of files is capped at 20 (in the onedrive connector).

https://powerusers.microsoft.com/t5/Flow-Ideas/List-files-in-folder-on-OneDrive-without-limit/idi-p/...

However, I used a work around as you can see in the flow below:cda.png

All you have to do is create a variable and put an integer value (I just put 100 here) and then in the condition branch where you are deleting the files, use the actions and logic as in the above screenshot. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

Hi @yashag2255 

 

I find it difficult how and where i must do it in  de existing Flow.

 

Dou you think like this?

 

Flow1.png

 

Flow1.png

Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

Hi @frixel 

 

Please follow these steps: 

 

Recurrence (trigger)-> Initialise the array variable -> initialise the integer variable with value 100-> do until action with variable and equals to 0 -> list files in a folder action -> apply to each action (put the value from the list files here) -> inside the apply to each action  -> comdition action (put both the conditions here) -> in the yes branch, append to array variable and use the same thing as in your flow -> delete file action. Now come out of the apply to each control and add an action delay (see in my flow) and then the set variable action (length fucntion here). Out of the do until control, create the HTML table and then the send email action. 

 

Hope this Helps!

 

 

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

What is the expresion by variable2?
@length(0) ?
Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

Hi @frixel 

it is

length(body('List_files_in_folder_2')?['value'])

IN your case it should be the List files in folder action. So in the expression editor, type length() and within the brackets, select body from the dynamic selector. 

 

Hope this Helps!

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

Hi @yashag2255 

 

You mean like this?

flow2.png

 

It doesn`t work, see the running time 😞

flow1.png

 

 

Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

@frixel 

 

can you share screenshot of the entire flow? I want to see why you are seeing two List files action outputs in the dynamic selector. Also what is the time you put in delay? (I put 10 seconds, you put 5 and check. you have 150 records and it should take 2-3 minute to complete the delete action and execute the flow)

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

Hi @yashag2255 

 

flow1.png

flow4.png

flow3.png

Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

@frixel 

Please move the delay and the set variable actions to the do until loop after the apply to each loop. it should work then.

frixel
Level: Powered On

Re: Delete files in OneDrive older than 30 days

Hi @yashag2255 

 

I made the adjustments as you say but no deleting files.

 

Flow1.png

Dual Super User
Dual Super User

Re: Delete files in OneDrive older than 30 days

@frixel 

 

Do you mean that not a single file has been deleted? Did you check on the one drive? Also, can you please confirm how many files are there in your one drive? There is a slight mistake in the flow that i created (what i created would delete everything). Can you share the number of folders in the one drive? 

 

We will have to modify the flow that first we get the files and check the date and then find the number of files and then check the variable. 

 

Hope this Helps!

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

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!

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 Solution Authors
Top Kudoed Authors
Users online (5,543)