delete folder/contents based on date
Posted on 2013-05-21
I have a test environment where I create a group of sub folders within a parent folder.
Each of the sub-folders has a number of documents in each.
I want to create a cron task that will run a script which will remove any subdirectory that is 2 days old.
My challenge is to cycle thru all contents of parentfolder, examine the date of each folder and if the date is older than 2 day delete the contents that folder and then the folder itself.
I don't know the names of the folders in advance
If I use code such as
who do I tell if the item is a folder or a file
This script doesn't need to be recursive, as there are not folders within subFolders