I am after a script that will delete all files and folders older than a specified number of days which the user inputs, but exclude certain folders and subfolder from deletion.
Path the script would run:
Root Folder: C:\inetpub\ftproot\LocalUser\
The root has hundreds of subfolders which I dont want deleted.
It should look into root folder, then scan each folder within it a delete the contents of that folder, but not the parent within the root folder, this would delete everything that is of a specified number of days.
I want to exclude these folders from the script so the content does not get deleted.
I have found many different versions, but they all relate to a singular folder.
Now I know I can add a "globaldepthcount" so i can specify the depth from the root folder..
GlobalDepthCount = 1
includeDepths = Array(GlobalDepthCount)', "2")
Then adding the rest of the code as a sub rountine..
But not being brilliant on scripting, I keep getting my subroutines in a mix..
So any help would be greatly appreciated.,
Essentially, all I want to do is run the script as a scheduled task, to clearout FTP Data from all ftp user account home folders, that being files and folders but exclude staff folders from being affected..