|
|
|||||||
I have the following script check \\server1\publicdr\scans for files over two days old and delete them. I've created a folder under \scans called ctx that I would also like to check. How can I use this script to check both folders w/o deleting the ctx folder, only the files inside of it? Code: Break On Call functions\timediff.udf Call functions\dirplus.udf $Dir = DirPlus("\\server1\publicdr\scans\","/a-d") For Each $File In $Dir 'Checking ' $File ' ' If TimeDiff(GetFileTime($File), 'now', 'd') > 2 "- File is more than 2 days old - deleting!" ? 'Del ' $File ' /S' ? Del $File EndIf Next Exit 0 |
||||||||
|
|
|||||||
Check if the file name is a directory. Code: If Not GetFileAttr($File) & 16 ; delete it EndIf |
||||||||
|
|
|||||||
If there are other folders, and the CTX folder is the only one you don't want to delete, I'd do something like: Code: $Files=DirList('root', 3) For Each $File in $Files If Right($File, 4) <> 'CTX\' If TimeDiff(GetFileTime($File), 'now', 'd') > 2 '- File is more than 2 days old - deleting!' ? 'Del ' $File ' /S' ? EndIf EndIf Next Change the value from 3 to 7 if you want to process subfolders, although I'd change the logic somewhat.. I'd search for files first, then make a second pass and only remove empty folders, excluding CTX\. Glenn |
||||||||
|
|
|||||||
The only folder will be \CTX so I want to look in that folder and delete anything older than 2 days and then scan the original folder. |