# How to find/delete files older than x days?

**URL:** <https://www.finalbuilder.com/forums/t/how-to-find-delete-files-older-than-x-days/7087>\
**Category:** Discussion\
**Created:** [August 3, 2021, 2:20pm UTC](https://www.finalbuilder.com/forums/t/how-to-find-delete-files-older-than-x-days/7087 "2021-08-03T14:20:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathanmeltzer](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jonathanmeltzer](https://www.finalbuilder.com/forums/u/jonathanmeltzer)\
**Post date:** [August 3, 2021, 2:20pm UTC](https://www.finalbuilder.com/forums/t/how-to-find-delete-files-older-than-x-days/7087/1 "2021-08-03T14:20:49Z")

</div>

Looking to find and delete all files older than X days (could be create date or modify date - does not really matter which). I looked at the Find Files and Delete Files actions, and there does not seem to be a way to find or delete files based on relative date. You can specify a specific calendar date, but not “2 days before current date”.

Am I missing something? I see a similar Finalbuilder question that someone asked in 2009, but am unable to view the solution project.

Thanks,

Jonathan

---

<div class="post-metadata">

**Author:** ![jonathanmeltzer](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jonathanmeltzer](https://www.finalbuilder.com/forums/u/jonathanmeltzer)\
**Post date:** [August 3, 2021, 3:07pm UTC](https://www.finalbuilder.com/forums/t/how-to-find-delete-files-older-than-x-days/7087/2 "2021-08-03T15:07:37Z")

</div>

Might have figured it out. Combination of File/Fileset Iterator, GetDate (on each file), GetDateTimeDifference (between the GetDate value and now), and an If statement checking to see if the GetDateTimeDifference is greater than X days. Unless there is an easier way?

---

<div class="post-metadata">

**Author:** ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)\
**Post date:** [August 3, 2021, 10:10pm UTC](https://www.finalbuilder.com/forums/t/how-to-find-delete-files-older-than-x-days/7087/3 "2021-08-03T22:10:57Z")

</div>

Hi Jonathan

Another option is Fileset Filters

 ![image](https://www.finalbuilder.com/forums/uploads/default/original/2X/e/ef66a1f22c765e6adff0ac703dbb87953760daa4.png)

Using a DateTime filter and a DateTime Variable

 ![image](https://www.finalbuilder.com/forums/uploads/default/original/2X/0/00e8a7bcc143b67793da2d8ffede3f68b649dd44.png)

---

<div class="post-metadata">

**Author:** ![jonathanmeltzer](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jonathanmeltzer](https://www.finalbuilder.com/forums/u/jonathanmeltzer)\
**Post date:** [August 4, 2021, 11:56am UTC](https://www.finalbuilder.com/forums/t/how-to-find-delete-files-older-than-x-days/7087/4 "2021-08-04T11:56:25Z")

</div>

I think I understand how that would work, but it is a confusing screen, because it looks like if it would match either the specified date/time OR the variable date/time it would be part of the fileset. I assume, though, that a variable in this screen would OVERRIDE the specified date/time. Is that correct?

---

<div class="post-metadata">

**Author:** ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)\
**Post date:** [August 4, 2021, 12:50pm UTC](https://www.finalbuilder.com/forums/t/how-to-find-delete-files-older-than-x-days/7087/5 "2021-08-04T12:50:52Z")

</div>

Yes, when you specify the variable the comparison date/time are ignored… I’ll see if we can’t make that clearer somehow.

---

<div class="post-metadata">

**Author:** ![jonathanmeltzer](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jonathanmeltzer](https://www.finalbuilder.com/forums/u/jonathanmeltzer)\
**Post date:** [August 4, 2021, 3:15pm UTC](https://www.finalbuilder.com/forums/t/how-to-find-delete-files-older-than-x-days/7087/6 "2021-08-04T15:15:24Z")

</div>

I actually do not see any tabs for “Include Patterns”, “Exclude Patterns”, or “Filters”. Is that a Finalbuilder thing? I am using Automise - I just see “General”, “Runtime” and “Details”.

EDIT: I am looking at the FileSet Iterator. I realize that you are in the Fileset Define screen. Sorry about that.
