Hi,
I would like to know how to delete all file that is in a folder in a library sharepoint, that are older than two days.
i've seeing a some flow on this user community but none of them is what I need...
--------------------------------------------------
exemple:
all the files that in the library Reporting in the folder Flow ( Reporting/Flow/ ) that are older than 2 days has to be delete everyday.
-----------------------------------------------------
So first, I now i have to put a recurrence of 1 day.
Second, If I'm correct i have to have the sahrepoint "Get files (properties only) ".
Third, i think i should have "Apply to each", the output has to be "Value" of the "Get Files"
but after that i don't know.
Hello,
I have a slightly different task, I need the flow to identify files within folders that are in WI library, and then if those are older than a year (based on modified date) I need them to move to a diff library WI expired, but the folders stay in WI, only files are moving.
I don´t want the folders to be considered in the flow (to be checked if they are older than a year) and then if the files are not older, nothing happens.
Thank you
JP21
Hey Scott,
Yeah I played with the OD field a little but couldn't come up with what magical code it was asking for.
I did finally get the foreach loop to work by playing around with the time syntax. I saw there was a 'created' tag so that wouldv'e been real fun if MS just allowed created gt/lt whatever 'time' but I guess they've started making things more difficult in recent years instead of easier.
Oh well. Luckily this is a very infrequent used share so if it ever get's up to more than 10-15 files in it we've got a big issue. 🙂
Thanks!
@Anonymous :
I have a couple of suggestions.
First, I suggest that you create a new post under a new topic with your question along with a screen shot of your current Flow. This will make it much easier to assist.
In addition, as I suggested above, you are much better off using an OData Filter in the Get Files (properties only) action. Looping through every file is inefficient and, depending on the number of files and your license, may not return all files due to Flow limits. In addition, you can only loop through a maximum of 5000 items unless you have a P2 license.
In your new post, can you explain your criteria a little more? Are you looking for files created within the last 2 hours?
Scott
I'm in the same boat but trying to find and delete all files that are older than 2 hours.
After going through about 15 examples I still can't get it to work. Very simple flow in my head but the syntax is a bit infuriating (makes powershell feel good).
Recurrence every 2 hours.
Get files (properties only). Only on the main Documents folder on the site. Single site.
foreach value; condition is where I hit a wall. Trying to do a utcnow(); greater than addminutes 120 but none of the syntax I can find works right.
Yes delete file 'identifier'.
Really not sure how created date and all of that doesn't get pulled into these but I guess reasons.
Any ideas?
Hi @Anonymous,
Do you want to delete all files which are older than 2 days within a folder of your SharePoint library?
I have made a test on my side and please take a try with the following workaround:
@equals(item()?['{Path}'], 'Reporting/Flow/')
@less(formatDateTime(addDays(item()?['Created'], 2), 'MM/dd/yyyy'), utcNow('MM/dd/yyyy'))
Within "If/yes" branch of Condition, add a "Delete file" action, specify Site Address and the File Identifier field set to following formula:
item()?['{Identifier}']
Image reference:
The flow works successfully as below:
Best regards,
Kris
Here is a simple example that I believe will work for you. I set the time to 2 minutes vs 2 days so it would be easier to test. My If statement looks for the folder name in the path - with a little work you can do better than that.
I am filtering the Get File Properties with the following expression: Created lt ' [Past Time]' where Past Time is a reference to the output of the Get Past Time action.
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional