Solved

Full file listing on specific drive

Posted on 2003-11-28
1
286 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now