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.
ie.
Parent Folder
Subfolder A
file1
file2
Subfolder B
file1
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
readdir($parentFolder)
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
Open in new window