how do i import a directory file list into an access table

C

CAD Geek

I am creating backup dvd's of folders and want to find a way to get a
directory strcuture into an access table with minimal pain. then I can query
on date folder filename etc.

Help. A newbe here.
 
J

John Nurick

Open a Command Prompt (MS-DOS Prompt) and havigate to the starting point
of the folder structure you're interested in (using the CD command and
drive letters).

Then run the command
DIR *.* /D /S /B
which will list the paths to all folders below the starting point.

Once you're satisfied with it, add a redirection clause to send the
command output to a text file, e.g.
DIR *.* /D /S /B > "C:\Temp\List of folders.txt"

You can then import the list from the text file into an Access table
where you can filter and parse it as required.


On Thu, 31 Mar 2005 12:29:02 -0800, "CAD Geek" <CAD
 
J

Joe Fallon

How to Add Directory File Names to an Access Table:

Create a table named tblDirectory with 2 fields:
FileName (Text 250)
FileDate (Date/Time)

Call the code below by pressing Ctrl-G to open the debug window and type:
GetFiles("c:\windows\")

Paste this code into a regular module:

Sub GetFiles(strPath As String)
Dim rs As Recordset
Dim strFile As String, strDate As Date

'clear out existing data
CurrentDb.Execute "Delete * From tblDirectory", dbFailOnError

'open a recordset
Set rs = CurrentDb.OpenRecordset("tblDirectory", dbOpenDynaset)

'get the first filename
strFile = Dir(strPath, vbNormal)
'Loop through the balance of files
Do
'check to see if you have a filename
If strFile = "" Then
GoTo ExitHere
End If
strDate = FileDateTime(strPath & strFile)
rs.AddNew
'to save the full path using strPath & strFile
'save only the filename
rs!FileName = strFile
rs!FileDate = strDate
rs.Update

'try for next filename
strFile = Dir()
Loop

ExitHere:
Set rs = Nothing
MsgBox ("Directory list is complete.")
End Sub
 

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

Top