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 50 51 52 53 54 55 56 57 58 59 60
| '
' Fonction GetDir(strPath,strPattern)
' Retourne un tableau classé des noms de fichiers valides
' au pattern qui est une expression régulière
' ** A Faire évoluer **
'
Function GetDir(strPath,strPattern)
Dim fso, Dossiers, fic, fichiers, strListe, f, i
Dim Valeur, imax, z, Cible, liste, Comp, Modele
Set fso = CreateObject("Scripting.FileSystemObject")
Set Dossiers = fso.GetFolder(Path)
Set fic = Dossiers.Files
Set Modele = new RegExp
Modele.pattern = strPattern
Modele.IgnoreCase = True
imax = 0
For Each fichiers In fic
Set f = fso.GetFile(fichiers)
imax = imax + 1
ReDim Preserve Tableau(2, imax)
Tableau(1, imax) = f.Name
Tableau(2, imax) = f.DateLastModified
Valeur = 0
For imax = 1 To imax - 1
If CDate(Tableau(2, imax)) < CDate(Tableau(2, imax + 1)) Then
For z = 1 To 2
Cible = Tableau(z, imax)
Tableau(z, imax) = Tableau(z, imax + 1)
Tableau(z, imax + 1) = Cible
Next
Valeur = 1
End If
Next
Next
liste = ""
For i = 1 To imax
Set Comp = Modele.Execute( Tableau(1, i) )
If Comp.Count > 0 Then
liste = liste & Tableau(1, i) & "/"
End If
Next
GetDir = Split( liste, "/", -1 )
Set fso = Nothing
Set Dossiers = Nothing
Set fic = Nothing
Set f = Nothing
Set Modele = Nothing
End Function |
Partager