1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Sub Lit_dossier(ByRef dossier As Object, ByVal niveau As Long, ByRef ligne As Long)
Dim objShell As Object, objFolder As Object, objItem As Object
Dim f As Object, d As Object, extension As String
Set objShell = CreateObject("Shell.Application")
' Entête du dossier
Cells(ligne, 1) = dossier.Path
Cells(ligne, 1).Interior.ColorIndex = 36
ligne = ligne + 1
' Fichiers
For Each f In dossier.Files
On Error Resume Next ' Ignore les erreurs sur les fichiers corrompus
Cells(ligne, 1) = dossier.Path
Cells(ligne, 2) = f.Name
extension = LCase(Mid(f.Name, InStrRev(f.Name, ".") + 1))
Cells(ligne, 3) = extension
Cells(ligne, 4) = f.Size
Cells(ligne, 5) = f.DateLastModified
' Attributs (exemple : Archive, Hidden, etc.)
Cells(ligne, 6) = AttrToString(f.Attributes) ' Fonction personnalisée ci-dessous
' Métadonnées audio
If InStr("mp3,wav,flac,aac,m4a", extension) > 0 Then
Set objFolder = objShell.Namespace(dossier.Path)
Set objItem = objFolder.ParseName(f.Name)
If Not objItem Is Nothing Then
' Remplacez les indices selon votre système !
Cells(ligne, 7) = objFolder.GetDetailsOf(objItem, 21) ' Titre
Cells(ligne, 8) = objFolder.GetDetailsOf(objItem, 20) ' Artiste
Cells(ligne, 9) = objFolder.GetDetailsOf(objItem, 14) ' Album
Cells(ligne, 10) = objFolder.GetDetailsOf(objItem, 27) ' Durée
End If
End If
ligne = ligne + 1
On Error GoTo 0
Next f
' Sous-répertoires
For Each d In dossier.SubFolders
Lit_dossier d, niveau + 1, ligne
Next d
Columns("A:J").AutoFit
End Sub |
Partager