How to delete the old folder using the attribute. DateLastAccessed
Posted on 2011-10-27
I need help with a difficult script that should delete the old folder pair, including all subfolders and files. Criteria for deleting components should be as follows:
1) Components are searched in the directory:
2) in the name of the folder must exist a point, but should not be at the beginning or end of the name.
Example folder names:
thomas.meyer -> delete folder
davidculter. -> Will not delete folder
wolfgangpeterson -> will not delete folder
3) If the component passes through the second criterion has to verify the existence of a pair.
This means that the script in addition to the local directory (see point 1) to search the network folder \\S3\HomeS$\ and find the folder that will be its name exactly match that of local.
Example pair of components:
4) The last approach to the components must be older than 270 days (will be using .DateLastAccessed), it would be easy to change this number.
5) The script, along with the names of folders and lists the variable %Computername% to a text file in the \\S2\Temp\del_folder.txt including the appropriate folder to delete it writes a text file
6) Finally, the script folder on the local and server-side deleted.
This script does not mean simple, the more I'll be glad for all of your help.
Thank you in advance.