You will need to use the attributes property of the folder to check if it has 
the system and hidden bits set.

replace the line 
CheckFolder(oSubFolder)
with

If oSubFolder.Attributes and 6 Then
    'skip the folder
Else
     CheckFolder oSubFolder
End If

That was not tested but should get you there.   If you don't have it get 
yourself the help file for vbscript here:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=2764

Mike Wiebke
Rapid Fire Solutions




________________________________
 From: Eric Wittersheim <[email protected]>
To: NT System Admin Issues <[email protected]> 
Sent: Thursday, December 20, 2012 4:32 PM
Subject: VB Script help needed
 

I found a VB script to check a folder and all its subfolders for files that are 
older than N days and either report how many files will get deleted if Active = 
True.  

The problem I have is that there is a hidden system folder inside of the 
folders that I am searching and I don't want to include that folder in this 
task.  Here is a copy of the script.  Anyone know how to accomplish this?  This 
script will run on a Windows 2008 R2 Server. 

Const Active = False
Const sSource = "J:\FTP_Data"
Const MaxAge = 30 'days
Const Recursive = True

Checked = 0
Deleted = 0

Set oFSO = CreateObject("Scripting.FileSystemObject")
if active then verb = "Deleting """ Else verb = "Old file: """
CheckFolder oFSO.GetFolder(sSource)

WScript.echo
if Active then verb = " file(s) deleted" Else verb = " file(s) would be deleted"
WScript.Echo Checked & " file(s) checked, " & Deleted & verb

Sub CheckFolder (oFldr)
For Each oFile In oFldr.Files
Checked = Checked + 1
If DateDiff("D", oFile.DateLastModified, Now()) > MaxAge Then
Deleted = Deleted + 1
WScript.Echo verb & oFile.Path & """"
If Active Then oFile.Delete
End If
Next

if not Recursive then Exit Sub
For Each oSubfolder In oFldr.Subfolders
CheckFolder(oSubfolder)
Next
End Sub

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to