Questions

How can I get my script to list sub folder information?

+
0 Votes
Locked

How can I get my script to list sub folder information?

robert.lee
Hi


I am kind of new to scripting and have nearly got my script to work but 1 last bit isn't working.

The aim of my script is to scan a folder and give me a list of requested fields for all files and sub folder files in a selected folder and out put it to a text file. At the moment it gives me all the information for the files in the root directory but not for any subfolders.


How can I edit my script to get this to work?

Thanks

Rob


Here is my script

Dim fso, folder, subFlds, files, OutputFile
Dim strPath

' Create a FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")

' Define folder we want to list files from
strPath = "Rob"

Set folder = fso.GetFolder(strPath)
Set subFlds = folder.SubFolders
Set files = folder.Files

' Create text file to output test data
Set OutputFile = fso.CreateTextFile("ScriptOutput.txt", True)

' Loop through each file
For each item In files

' Output file properties to a text file
OutputFile.WriteLine("Name= ")
OutputFile.WriteLine(item.Name)
OutputFile.WriteLine("")
OutputFile.WriteLine("DateCreated= ")
OutputFile.WriteLine(item.DateCreated)
OutputFile.WriteLine("")
OutputFile.WriteLine("DateLastAccessed= ")
OutputFile.WriteLine(item.DateLastAccessed)
OutputFile.WriteLine("")
OutputFile.WriteLine("DateLastModified= ")
OutputFile.WriteLine(item.DateLastModified)
OutputFile.WriteLine("")
OutputFile.WriteLine("Drive= ")
OutputFile.WriteLine(item.Drive)
OutputFile.WriteLine("")
OutputFile.WriteLine("ParentFolder= ")
OutputFile.WriteLine(item.ParentFolder)
OutputFile.WriteLine("")
OutputFile.WriteLine("Path= ")
OutputFile.WriteLine(item.Path)
OutputFile.WriteLine("")
OutputFile.WriteLine("Size= ")
OutputFile.WriteLine(item.Size)
OutputFile.WriteLine("")
OutputFile.WriteLine("Type= ")
OutputFile.WriteLine(item.Type)
OutputFile.WriteLine("------------------------------------------------")
OutputFile.WriteLine("")

Next

' Close text file
OutputFile.Close