Insert data from file names?

M

Mark Bratanov

I was wondering if there was ANY way to insert data into the database
according to 1000's of individual pdf File names.

Example:

CLG Doc #1234_000B22.pdf

Could then be entered into the database as is. I have so many files that it
would be to time consuming to do what I want to do. I really appreciate your
time, Thanks.
 
O

OceansideDJ

Mark,
This may be a kludge, but it works.

From the Start menu, select Run... and type cmd, then hit OK. This gives a DOS
prompt.

Navigate into the folder holding your files, and type DIR/B >dir.txt

This creates text file dir.txt, which can now be imported in Access as a table.

Mike
 
S

SteveD

you can try this.

using the dos command DIR, you can create a file of the directories contents
into a text file. Then import the text file into access, with the right
importing, you can have a list of all the files that you were looking for.

I did this manually, but could probably be set-up in a bat file and be run
automatically when you need.
Here's the command sequence to create a text file:

dir > C:\YourPath\YourFileName.txt YourDataPath\*.pdf

Now you'll have a text file of all the contents. Import this into access.
You should be able to use this data instead of manually creating it.

HTH

SteveD
 
D

Douglas J. Steele

If you want to do everything in code, rather than creating a text file and
importing it. Access has a built-in Dir function.

Dim strFolder As String
Dim strFile As String
Dim strSQL As String

strFolder = "C:\Folder1\Folder2\"
strFile = Dir(strFolder & "*.pdf")
Do While Len(strFile) > 0
' strFile will contain the file name of the "first" file in
' the folder. Insert it into the table, manipulate it, or
' do whatever else you want. For instance:
strSQL = "INSERT INTO MyTable (FileNm) " & _
"VALUES (" & Chr$(34) & strFile & Chr$(34) & ")"
CurrentDb().Execute strSQL, dbFailOnError
strFile = Dir()
Loop
 

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