Damarado
asked on
Script to clean up folders and sub folders on file server
Hi
I am looking for a script that will run on a scheduled weekly task and deletes any content in the folders older then one week.
Our file server is running windows 2012.
There are users with root and sub folders as shown
user jreeds
subfolders jreeds-a1
jreeds-a2
jreeds-a3
jreeds-a4
jreeds-a5
I only want the content scrubbed from the sub folders for each user, not the root folder for the user
Any files older than a week will be deleted, otherwise left alone.
any new folders in the sub folders will not be touched.
Thanks
I am looking for a script that will run on a scheduled weekly task and deletes any content in the folders older then one week.
Our file server is running windows 2012.
There are users with root and sub folders as shown
user jreeds
subfolders jreeds-a1
jreeds-a2
jreeds-a3
jreeds-a4
jreeds-a5
I only want the content scrubbed from the sub folders for each user, not the root folder for the user
Any files older than a week will be deleted, otherwise left alone.
any new folders in the sub folders will not be touched.
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
And you only want to remove old files from:
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
And not:
x:\basedir\jreeds\
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
x:\basedir\jreeds\jreeds-a
If so, are the a1 through a4 always constant and the same and should be hard coded, or could they be any name that lives at the first level of the user folder?
~bp