Server File Listing

  • Thread starter Thread starter The Question guy
  • Start date Start date
T

The Question guy

I'm looking to create an Access Module to help create an inventory of a
specific file type (i.e. .txt or .xls).

Essentially, I want to be able to capture: File path, file name, file owner,
file size, date last modified, and the time/date the inventory was run.

Any idea of a VB script that I could use to populate a table(s) with this
info?
 
On Tue, 25 Nov 2008 14:58:00 -0800, The Question guy

One unconventional way to do this is in a command window:
dir c:\*.txt /s /b > c:\test.txt
Then import that file into a table.

A more conventional way is to use the Dir command recursively to
iterate over the folders.

-Tom.
Microsoft Access MVP
 
Hi,

If you do not really need the file owner, you can use the
FileSystemObject. It required the Microsoft Scripting Runtime (in VBA
Editor, Tools menu, References item). Here is some code that demonstrates
get folders and files and subfolders.

Public Sub GetFileInformation(ByVal strPath As String)

Dim fl As File
Dim fso As New FileSystemObject
Dim fldr1 As Folder
Dim fldr2 As Folder

MsgBox "Processing " & strPath

Set fldr1 = fso.GetFolder(strPath)
For Each fl In fldr1.Files
MsgBox "Name: " & fl.Name & vbCrLf & _
"DateCreated: " & fl.DateCreated & vbCrLf & _
"DateLastAccessed: " & fl.DateLastAccessed & vbCrLf & _
"DateLastModified: " & fl.DateLastModified & vbCrLf & _
"Drive: " & fl.Drive & vbCrLf & _
"ParentFolder: " & fl.ParentFolder & vbCrLf & _
"Path: " & fl.Path & vbCrLf & _
"Size: " & fl.Size & vbCrLf & _
"Type: " & fl.Type & vbCrLf & _
"Extension: " & fso.GetExtensionName(fl.Name)
Next fl
For Each fldr2 In fldr1.SubFolders
GetFileInformation fldr2.Path
Next fldr2

End Sub

Hope that helps,

Clifford Bass
 
On Tue, 25 Nov 2008 20:14:02 -0800, Clifford Bass

Your onor, assuming facts not in evidence

-Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top