'Deleting files within a folder and its subfolders that are older than x days using nested loops (bash in unix)

for filelist in $folder/Archived_MDL_files
do
    if [ -d $folder/Archived_MDL_files ]
    then
        find $folder/Archived_MDL_files/* -mindepth 1 -mtime +240 -delete;
            :
    #fi
done

the code uses BASH in UNIX and I'm trying to delete files in all folders (subfolders included) that are older than 240 days (6 months), trying to figure out the correct syntax for BASH but not too sure if I am correct or not. The target folder only has a single type of file, numbering in millions, so I wish to do some housekeeping to conserve space. This block of code is part of another for loop indicating the base directory.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source