Delete files after 30 days

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 - Are you planning to do this in Studio or StudioX?

@prasath17 I am planning to do in studioX

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

1 Like

@prasath17 thanks man!! can you post this into a .xaml process if you don`t mind

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

@utsav.patel - What version of the UiPath are you using??

Hold on…But you said you want to do this in StudioX? why are you looking at in Studio Pro??

Sorry @prasath17 my license has expired for studio x and we upgraded to pro now.

@utsav.patel - Please let me know what version of studio Pro you are using??

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… :wink:


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.