Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Get Filenames, Paths, File Properties Into Access 1

Status
Not open for further replies.

VelNPS

Programmer
Dec 5, 2003
8
US
I have a large number of files on a network. We would like to do some housekeeping and create some libraries. I would like to run through the windows directory structure starting with some drive folder and get all of the files, their paths, the author, date, subject, keywords and comments from the file properties and put them in an Access table.

This sounds like one of those classic recursion problems that somebody has already solved. Any Ideas where I may find a solution? Has anybody seen some shareware that already does something similar to help organize and weed through files?

Thank You, Vel
 
I have used this function to return only the DateLastModified, however, you can modify it to return any number of allowed properties (e.g. DateCreated, Drive, Name, Path, Size, etc.). For your specific needs, however, instead of defining a function, perhaps you would setup a For...Next loop with the end counter being the return of the count of files within the specific directory you want to archive and then appending all of these values into a table, per file.

I hope this helps...

EastWind
========================================================
Private Function LastModifiedDate(ByVal InvFileName As String) As Date

Dim FSO As Scripting.FileSystemObject
Dim InventoryName As Scripting.File

Set FSO = CreateObject("Scripting.FileSystemObject")
Set InventoryName = FSO.GetFile(InvFileName)

LastModifiedDate = InventoryName.DateLastModified

Set FSO = Nothing
Set InventoryName = Nothing

End Function
 
Here are a couple of functions that I set up to look for crystal reports in a directory structure. This will look through the directory and all sub directories.

Function ReadDirectoryStucture()

Dim fso, SearchPath As Variant
Dim Extension As String
Extension = "rpt"
Set fso = CreateObject("Scripting.FileSystemObject") ' Create global object

SearchPath = "X:\Report Development"
Debug.Print UCase(Extension)
'call the function MySearch
Call MySearch(SearchPath, Extension, fso) ' Designed to return table rows...
Set fso = Nothing
End Function

Function MySearch(Path, Extension, fso)

Dim Folder, FileList, File, Parts, SubFolder As Variant
Set Folder = fso.GetFolder(Path)
Set FileList = Folder.Files
For Each SubFolder In Folder.SubFolders
If Left(SubFolder.Name, 6) = "abc" Then
Exit For '- Get permission error on some folders.
End If
MySearch = MySearch(Path & "\" & SubFolder.Name, Extension, fso)
Debug.Print "------ Folder is " & Path & "\" & SubFolder.Name
Next
For Each File In FileList
If Not File.Type = "Crystal Report" Then
GoTo GetNext
End If
Debug.Print "File name = " & File.Name & " Type = " & File.Type
Parts = Split(File.Name, ".")
If UCase(Parts(UBound(Parts))) = UCase(Extension) Then
MySearch = MySearch & File.Path
End If
GetNext:
Next
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top