Private Sub Command1_Click() MP3s = GetAllFiles("E:\SimpleMP3s", "*.mp3", True).Count End Sub
Function GetAllFiles(ByVal Path As String, ByVal filespec As String, Optional RecurseDirs As Boolean) As Collection Dim spec As Variant Dim file As Variant Dim subdir As Variant Dim subdirs As New Collection Dim specs() As String
' initialize the result Set GetAllFiles = New Collection
' ensure that path has a trailing backslash If Right$(Path, 1) <> "\" Then Path = Path & "\"
' get the list of provided file specifications specs() = Split(filespec, ";")
' this is necessary to ignore duplicates in result ' caused by overlapping file specifications On Error Resume Next
' at each iteration search for a different filespec For Each spec In specs ' start the search file = Dir$(Path & spec) Do While Len(file) ' we've found a new file If HeleStien = True Then file = Path & file Else file = file End If GetAllFiles.Add file, file List1.AddItem GetAllFiles.Item(file) 'LavDirTræ Path, GetAllFiles.Item(file), True ' get ready for the next iteration file = Dir$ Loop Next
' first, build the list of subdirectories to be searched If RecurseDirs Then ' get the collection of subdirectories ' start the search file = Dir$(Path & "*.*", vbDirectory) Do While Len(file) ' we've found a new directory If file = "." Or file = ".." Then ' exclude the "." and ".." entries ElseIf (GetAttr(Path & file) And vbDirectory) = 0 Then ' ignore regular files Else ' this is a directory, include the path in the collection file = Path & file subdirs.Add file, file End If ' get next directory file = Dir$ Loop ' parse each subdirectory For Each subdir In subdirs ' use GetAllFiles recursively For Each file In GetAllFiles(subdir, filespec, True) GetAllFiles.Add file, file
Opret 3 list'bokse; listKunstner, listAlbum og listNummer Indsæt derefter nedenstående sub:
Private Sub OpstilMp3er(Filsti As String) Dim MP3array() As String MP3array() = Split(Filsti, "\") listKunstner.AddItem MP3array(UBound(MP3array) - 2) listAlbum.AddItem MP3array(UBound(MP3array) - 1) listNummer.AddItem MP3array(UBound(MP3array)) End Sub
Husk at erstatte linjen "List1.AddItem GetAllFiles.Item(file)" med "OpstilMp3er (Path & file)" (cirka midt i koden) Skriv hvis du er i tvivl om noget... -Sion
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.