Collecting MP3 file information

drewby

New member
Local time
Today, 12:24
Joined
Mar 18, 2006
Messages
5
I found VBA code for Excel that collects various bits of information for mp3 files from a directory and sub-directories that the user selects.
http://j-walk.com/ss/excel/tips/tip103.htm
<a HREF="http://j-walk.com/ss/excel/tips/tip103.htm">http://j-walk.com/ss/excel/tips/tip103.htm</a>

I would like to utilize this code in Access with the results that are returned to worksheet Sheet 1 being appended to an Access table. I'm not interested in the Pivot Table results.

Any suggestions?
 
Are you just trying to get the data...or imitate the code in Access?
 
Trying to Imitate Excel code in Access

I am trying to imitate the aforementioned Excel code in Access.

I have some proprietary Radio DJ software that can generate "random" playlists based on certain criteria you feed it in the form of text files. Things such as genre and so forth. But it is also capable of playing a specific mp3 file if you feed it the full file path. I have about 20 different playlist templates and am interested in incorporating some select podcasts into my radio stream at the top of every hour. I want to use access to catalog all of my mp3 podcast files, store a list of podcasts that I would like to be played at the top of every hour for the upcoming week, and then generate new text file playlist templates with the embedded mp3 file path at the desired point.

I have everything in place except this. I have a set of "append" queries set up that will only add recently added mp3 files to my catalog. I am exporting a report as text file for my playlist templates.
 
Sounds like you will need to call some Windows APIs; to get to the file properties of the selected diretory. Dev Ashish's site might have something...otherwise I am sure there are alot of folks in here who are well versed!
 
Have you looked at the code in the visual basic editor in the spreadsheet to see if you can manipulate that?
 
Did you figure out how to do this? This seems really interesting. Thanks.
 
Found some other code

I did find another source of code (posted below) that works. However, it only retrieves file name, path and date. It doesn't retrieve any of the information embedded within the mp3 file itself. You also have to hard code the directory in which it begin its search.

**********************

Option Compare Database
Option Explicit

Dim gCount As Long ' added by Crystal

Sub runListFiles()
'Usage example.
Dim strPath As String _
, strFileSpec As String _
, booIncludeSubfolders As Boolean _
, strSQL As String

strPath = "C:\Documents and Settings\Drew Brumbaugh\My Documents\My Received Podcasts"
strFileSpec = "*.*"
booIncludeSubfolders = True
strSQL = "DELETE * FROM DirFiles;"
CurrentDb.Execute strSQL
gCount = 0

ListFilesToTable strPath, strFileSpec, booIncludeSubfolders
End Sub

'crystal modified parameter specification for strFileSpec by adding default value
Public Function ListFilesToTable(strPath As String _
, Optional strFileSpec As String = "*.*" _
, Optional bIncludeSubfolders As Boolean _
)
On Error GoTo Err_Handler
'Purpose: List the files in the path.
'Arguments: strPath = the path to search.
' strFileSpec = "*.*" unless you specify differently.
' bIncludeSubfolders: If True, returns results from subdirectories of strPath as well.
'Method: FilDir() adds items to a collection, calling itself recursively for subfolders.

Dim colDirList As New Collection
Dim varitem As Variant
Dim rst As DAO.Recordset

Dim mStartTime As Date _
, mSeconds As Long _
, mMin As Long _
, mMsg As String

mStartTime = Now()
'--------

Call FillDirToTable(colDirList, strPath, strFileSpec, bIncludeSubfolders)

mSeconds = DateDiff("s", mStartTime, Now())

mMin = mSeconds \ 60
If mMin > 0 Then
mMsg = mMin & " min "
mSeconds = mSeconds - (mMin * 60)
Else
mMsg = ""
End If

mMsg = mMsg & mSeconds & " seconds"

MsgBox "Done adding " & Format(gCount, "#,##0") & " files from " & strPath _
& IIf(Len(Trim(strFileSpec)) > 0, " for file specification --> " & strFileSpec, "") _
& vbCrLf & vbCrLf & mMsg, , "Done"

Exit_Handler:
SysCmd acSysCmdClearStatus
'--------

Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & ": " & Err.Description, , "ERROR"

'remove next line after debugged -- added by Crystal
'Stop: Resume 'added by Crystal

Resume Exit_Handler
End Function

Private Function FillDirToTable(colDirList As Collection _
, ByVal strFolder As String _
, strFileSpec As String _
, bIncludeSubfolders As Boolean)

'Build up a list of files, and then add to this list, any additional folders
On Error GoTo Err_Handler

Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
Dim strSQL As String
Dim FileDate As Date

'Add the files to the folder.
strFolder = TrailingSlash(strFolder)
strTemp = Dir(strFolder & strFileSpec)
'dtCreated = f.dateCreated

Do While strTemp <> vbNullString
gCount = gCount + 1
SysCmd acSysCmdSetStatus, gCount
FileDate = FileDateTime(strFolder & strTemp)
strSQL = "INSERT INTO DirFiles " _
& " (FName, FPath , FDate) " _
& " SELECT '" & strTemp _
& "', '" & strFolder _
& "', #" & FileDate & "#;"
CurrentDb.Execute strSQL
colDirList.Add strFolder & strTemp
strTemp = Dir
Loop

If bIncludeSubfolders Then
'Build collection of additional subfolders.
strTemp = Dir(strFolder, vbDirectory)
Do While strTemp <> vbNullString
If (strTemp <> ".") And (strTemp <> "..") Then
If (GetAttr(strFolder & strTemp) And vbDirectory) <> 0& Then
colFolders.Add strTemp
End If
End If
strTemp = Dir
Loop
'Call function recursively for each subfolder.
For Each vFolderName In colFolders
Call FillDirToTable(colDirList, strFolder & TrailingSlash(vFolderName), strFileSpec, True)
Next vFolderName
End If

Exit_Handler:

Exit Function

Err_Handler:
strSQL = "INSERT INTO Files " _
& " (FName, FPath) " _
& " SELECT "" ~~~ ERROR ~~~""" _
& ", """ & strFolder & """;"
CurrentDb.Execute strSQL

Resume Exit_Handler
End Function

Public Function TrailingSlash(varIn As Variant) As String
If Len(varIn) > 0& Then
If Right(varIn, 1&) = "\" Then
TrailingSlash = varIn
Else
TrailingSlash = varIn & "\"
End If
End If
End Function

****************
 
I meant trying to find out the id3 tags, so that I could see the id3 tags of the file.
 
I believe it could be done...since he is letting you use the dlls...

Install the program; then go into Access and set the references in the IDE window, to the DLL file names (they might have a different title than the file names so watch for those).

Now you should be able to use his object model to reveal the MP3 tag info.

One of the changes you would make in the loop, would be to add the line that appends the collected data into one of your database tables.
 
If anyone is still interested I just posted an access catalog program which will read MP3 ID1 and 2 tag information and then catalog it. You will find it in this forum.

Cheers
Tonez90

Sorry Here is the link:
http://www.access-programmers.co.uk/forums/showthread.php?t=187853
I have just updated the DB to add some functionality. I have also a bigger version which has extra find functions and is much quicker in finding etc. I will try and post it today but if It is not the version marked 19-Feb-10 please send me a message and I will try and post it to you.
 
Last edited:
You should add a link to your posted db in this thread to help those in future need.
 
actually access (or some dbs) seems ideal as a base for playing stuff - i bet windows media player has something like that at its heart. it wouldnt just work from a non-indexed file, would it?

there are loads of mdb files on your hard disk, if you search for them.

i will have a look for tonez link, methinks.

[edited - yes very interesting, and well locked down, too! - lots of tricks in there]
 
Last edited:

Users who are viewing this thread

Back
Top Bottom