Solved

Full file listing on specific drive

Posted on 2003-11-28
1
290 Views
Last Modified: 2010-05-01
Hi,

I am trying to develop and Achive Policy for my office. Before I can decide what is the most appropriate and effective method to use I need to examine the files on the network dirves. I intended to get a list of all the files, including all other relevant information such as "Modified Date", "Last Accessed Date", etc. I would then import this list into Access/Excel and then run some statistics on usage, dates, locations, etc.

The problem I am having is that I CAN get a list of files and sub-folders for a particular folder that I specify, but how do I can a list of all the files starting from the root of the hard drive. I thought that this may have been a easy process but there are folders under folders under folders and so on.

I am using MS VBScript with IE 6.01. The operating system is Windows NT 4.00 SP6a but should work with Active Directory as well.

Help would much appreciated.

Thanks
0
Comment
Question by:AlvanRowland
1 Comment
 
LVL 14

Accepted Solution

by:
aelatik earned 75 total points
ID: 9839244
Since you know how to get the propertys you only have to implement a recursice file search :

Dim FSO, FSO_DIRECTORY, FSO_FILES, FSO_DIRECTORYS

Function DirectoryInformation(folder)
        Set FSO = CreateObject("Scripting.FileSystemObject")
        On Error Resume Next
        Set FSO_DIRECTORY = FSO.GetFolder(folder)
        Set FSO_FILES = FSO_DIRECTORY.Files
        Set FSO_DIRECTORYS = FSO_DIRECTORY.Subfolders
            If FSO_FILES.Count > 0 Then
                    For Each FSO_FILE In FSO_FILES
                        If FSO_FILE <> "" Then MsgBox FSO_FILE
                    Next FSO_FILE
            End If
            If FSO_DIRECTORY.Count > 0 Then
                For Each FSO_SUBDIRECTORY In FSO_DIRECTORYS
                    DirectoryInformation (FSO_SUBDIRECTORY)
                Next
            End If
        Set FSO_DIRECTORY = Nothing
        Set FSO_FILES = Nothing
        Set FSO_DIRECTORYS = Nothing
End Function

' usage

Call DirectoryInformation("c:\")

I copied it from my VB project so you have to change msgbox to something else ( wscript.echo )
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question