'choix du répertoire nomrep=inputbox("nom du répertoire",,"c:\mes documents") 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 "nom de ré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",,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="
Contenu du répertoire " & nomrep & "
(" & nb_niveaux_max-1 & " niveau" & esse & ")


" 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 & "
" & chr(10) 'fichiers if col" & fch.name & "
" & 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 & "
" '----------------------------------------------- '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