Hello All,
I am working on a script of moving files but i want to delete the files from that folder after 30 days. Any idea on how should i proceed ?
@utsav.patel - here you go…
XAML Image
Condition Builder (If Condition)
Choose Last Modified Date
Choose Offset and Type -30 and Type is Days
Click + in the IF and choose advance Editor and add .tostring at the end if not it will throw an error…
Write Line Output
Before Delete
After Delete
Hope this helps…
@utsav.patel - Yes, I can post it…But have you tried from the screenshot which I already shared??
If yes, it is working? if not, what is the error you are facing??
I do not see all these activities in my studio pro like i cannot locate the condition builder you showed in image.
Hold on…But you said you want to do this in StudioX? why are you looking at in Studio Pro??
Sure! Version for my studio pro is 2020.10.4
Thanks for letting me. If possible change this query category from StudioX to Studio…I will share the code in a minute
Thanks , appreciate for help
@utsav.patel - Here is the one line code, using Invoke code you can achieve it…
Code:
array.ForEach(Directory.GetFiles("YourFolderPath").Where(Function(x) New FileInfo(x).LastWriteTime.Date < Today.Date.AddDays(-30)).ToArray,Sub(x) File.Delete(x))
If are would like to proceed with regular method…take the below code and paste it in the For each and then use Delete activity…
Directory.GetFiles("YourFolderPath").Where(Function(x) New FileInfo(x).LastWriteTime.Date < Today.Date.AddDays(-30))
Thank you !! let me add this and i`ll let you know.