cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

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 III
Dual Super User III

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!

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 III
Dual Super User III

@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!

Hi @yashag2255 

 

Thanks, i changed the "ticks"☺

But i have this error when i changed the pagination.

Flow1.png

Dual Super User III
Dual Super User III

@frixel 

 

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

Hi @yashag2255 

 

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

 

Flow1.png

Dual Super User III
Dual Super User III

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

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 III
Dual Super User III

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!

 

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 III
Dual Super User III

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!

 

 

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

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!

Hi @yashag2255 

 

You mean like this?

flow2.png

 

It doesn`t work, see the running time 😞

flow1.png

 

 

Dual Super User III
Dual Super User III

@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)

Hi @yashag2255 

 

flow1.png

flow4.png

flow3.png

Dual Super User III
Dual Super User III

@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.

Hi @yashag2255 

 

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

 

Flow1.png

Dual Super User III
Dual Super User III

@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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (11,976)