Putting file names in database

  • Thread starter Thread starter Darth Threepio
  • Start date Start date
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?
 
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.
 

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