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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| 'choix du répertoire
nomrep=inputbox("Chemin du r" & Chr(233) & "pertoire",,"G:\Musiques")
Set sh = WScript.CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
'traiter le cas où nomrep est un disque ou un nom non valide
if not fs.folderexists(nomrep) or ucase(fs.getdrivename(nomrep))=ucase(replace(nomrep,"\","")) then
MsgBox "Chemin du r" & Chr(233) & "pertoire non valide"
wscript.quit
end if
Set rep=fs.getFolder(nomrep)
spc=" "
'-----------------------------------------------
'créer un tableau contenant tous les noms de répertoires avec leur niveau
nb_niveaux_max=inputbox("Nombre de niveaux de recherche",,1)
if not isnumeric(nb_niveaux_max) or nb_niveaux_max=0 then nb_niveaux_max=1
nb_niveaux_max=nb_niveaux_max+1
redim reps(nb_niveaux_max,1)
'initialiser le tableau
reps(0,0)=rep.path
'remplir le tableau
explore 0,0
'-----------------------------------------------
'texte de sortie
esse=""
if nb_niveaux_max-1>1 then esse="x"
'balayer le tableau pour créer le txt de sortie
txt="<HTML><BODY BGCOLOR='ivory'><STYLE> A {text-decoration:none}</STYLE><BR><CENTER><FONT SIZE='+1'>Contenu du r" & Chr(233) & "pertoire " & nomrep & "</FONT><BR>(" & nb_niveaux_max-1 & " niveau" & esse & ")</CENTER><BR><BR><DIR>"
for lin=0 to ubound(reps,2)
blancs=""
for col=0 to ubound(reps,1)
tt=reps(col,lin)
if tt="" then
blancs=blancs & spc
else
set rpt=fs.getfolder(tt)
'enregistrer le nom du répertoire et les fichiers
txt=txt & blancs & rpt.name & "<BR>" & chr(10)
'fichiers
if col<nb_niveaux_max-1 then
for each fch in rpt.files
txt=txt & blancs & spc & "<A HREF='" & fch.path & "' target='_blank'><FONT COLOR='blue' SIZE='-1'>" & fch.name & "</FONT></A><BR>" & chr(10)
next
end if
exit for 'on arrete de balayer la ligne
end if
next 'col
if tt="" then exit for
next 'lin
txt=txt & "</DIR></BODY></HTML>"
'-----------------------------------------------
'afficher les résultats
fichresult="c:\rien.html"
Set nouv_fich = fs.OpenTextFile(fichresult, 2, true)
nouv_fich.write txt
nouv_fich.close
sh.run "iexplore " & fichresult
'--------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------
sub explore(lin,col)
'met à jour tableau reps(numéro,niveau)
set rep=fs.getFolder(reps(col,lin))
for each ssrep in rep.subfolders
if col<ubound(reps,1)-1 then 'limite le nb de niveaux
decale(lin)
reps(col+1,lin+1)=ssrep.path
lin=lin+1
explore lin,col+1
end if
next
end sub
'--------------------------------------------------------------------------------------------------------------------
sub decale(ln)
'fait de la place sous la ligne ln
redim preserve reps(ubound(reps,1),ubound(reps,2)+1)
for nln=ubound(reps,2) to ln+2 step -1
for ncl=0 to ubound(reps,1)
reps(ncl,nln)=reps(ncl,nln-1)
next
next
'vider ligne ln+1
for ncl=0 to ubound(reps,1)
reps(ncl,ln+1)=""
next
end sub
'-------------------------------------------------------------------------------------------------------------------- |
Partager