Putting file names in database

D

Darth Threepio

Given a folder that contains a bunch of .jpg images, is there a way to
automate putting each file name into a separate row of a database or
spreadsheet?
 
D

Douglas J. Steele

Something along the lines of:

Dim strFile As String
Dim strSQL As String

strFile = Dir("C:\MyFolder\*.jpg")
Do While Len(strFile) > 0 Then
strSQL = "INSERT INTO MyTable (FileName) " & _
"VALUES (" & Chr$(34) & strFile & Chr$(34) & ")"
CurrentDb().Execute strSQL, dbFailOnError
strFile = Dir()
Loop

Note that strFile will not include the folder. Change the SQL statement as
appropriate for your database.
 
Top