I have this script written in Powershell to delete files from a server using its creation date.
$datapath = "C:\Users\Alumno\Desktop\test"
dir $datapath| ?{($_.creationtime.adddays(2) -lt (get-date))} | remove-item -force -Recurse
How could I make the files ONLY? That is to say, that whenever you execute the script all the old files are deleted but that the folders, however old they are, remain intact.