script to find all files in folder/subfolders
- From: speedstic <speedstic@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 22 Feb 2008 11:30:00 -0800
Hello All,
I am trying to write a script to generate a log of all the files in a
folder, including sub-folders but I can't get the subfolder part to work.
Here is what i have so far...
--beginning--
strComputer = "."
logFile = "c:\test.txt"
count = 0
Const ForWriting = 2
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCreateFile = objFSO.CreateTextFile(LogFile)
objCreateFile.Close
Set objCreateFile = objFSO.OpenTextFile(LogFile, ForWriting)
objCreateFile.WriteLine "Starting search at " & date() & ", " & time() & "..."
objCreateFile.Close
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='c:\test\'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFileList
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_Datafile")
file_name = "Filename: " & objFile.Name
last_access = " Last Modified: " & objFile.LastModified
file_size = "Size: " & objFile.FileSize
count = count+1
Set objEditFile = objFSO.OpenTextFile(LogFile, ForAppending)
objEditFile.WriteLine count & ": " & file_name & ", " & last_access & ", "
& file_size
objEditFile.Close
Next
Wscript.Echo count
--end--
It works for finding the files in a folder, but not the files inside
subfolders.
Any help would be greatly appreciated!
.
- Follow-Ups:
- Re: script to find all files in folder/subfolders
- From: Pegasus \(MVP\)
- Re: script to find all files in folder/subfolders
- Prev by Date: script to monitor change in group membership
- Next by Date: Re: script to find all files in folder/subfolders
- Previous by thread: script to monitor change in group membership
- Next by thread: Re: script to find all files in folder/subfolders
- Index(es):
Relevant Pages
|
Loading