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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

storing filepath on a table

Status
Not open for further replies.

locosh

Technical User
Nov 12, 2001
9
0
0
US
hello,

I have a collection of MP3 files that I like to keep organized on an Access db. I have seen a program called MP3BOSS that scans a particular drive or folder and subfolders for mp3 files and then stores the filepath on a table. For example, I have my mp3 collection on the F:\Music folder and I would like a field called Filepath on a table to show the full filepath (ie. F:\Music\Enigma\Return to Innocence.mp3) of all the mp3 files in that folder. MP3Boss uses a button on a switchboard to show a form where the folder to be scanned is defined and a button that triggers the scanning process. Any ideas on how to accomplish this?

Hopefully I didn't lose you with this messy request but if I did let me know and I'll try to explain better.

Thanks!
 
This code below should do the trick

Private Sub Command12_Click() '<-- Change to your Button Name

Dim MyFolder As String 'Text Field on Form
Dim MyPath As String
Dim MyFile As String
Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset(&quot;Table_Name_That_Stores_MP3_Location&quot;, dbOpenDynaSet)

MyFolder = Me!Searchfolder
' Get the search path.
MyPath = MyFolder & &quot;\&quot; & &quot;*.mp3&quot;
' Get the first file in the path containing the file extension.
MyFile = Dir(MyPath, vbNormal)
Do While Len(MyFile) <> 0
'prepare the table for adding the file path
rs.AddNew
'Put the path of the first file into the table
rs.Field(0).Name = MyFile 'This Assumes that the first field in the table is the path table. If Not change the 0 to the number the field is in the table. Remember Numbering of fields start at 0
'update the table
rs.update
' Check for next file in the folder.
MyFile = Dir
Loop
rs.Close
Set rs = Nothing
End Sub

let me know if you have any problems.

HTH
Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
How do I write file information (name, attributes, owner, last updated) from any given directory including all it's subfolders to a table?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top