Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enumerate sub-directory names by date.

Status
Not open for further replies.
Apr 5, 2005
1,484
US
I am trying to enumerate the Names of folders (sub dirs) under the user directory on my file server. I would like to gather the names of the folders base on the creation date.
For example: give me the names of the folders that were created in the user directory within the last 7 days.
Any assistance or pointers would be appreciated.



I have found scripts that enumerate sub dirs as well as scripts that will enumerate all dirs based on creation date. But, not the action im looking for.
 
OK here is the basic code for what I was looking for, just posting if you were interested. Next I have to create a Function to convert the date code but Im good with that...
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSubfolders = objWMIService.ExecQuery _
    ("ASSOCIATORS OF {Win32_Directory.Name='c:\data\users'} " _
        & "WHERE AssocClass = Win32_Subdirectory " _
            & "ResultRole = PartComponent")
For Each objFolder in colSubfolders
    If objFolder.CreationDate > "20061101000000.000000-420" Then 
    Wscript.Echo objFolder.Name
    Else
    End If
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top