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
| Const ForReading = 1
Const ForWriting = 2
Titre = "Rechercher dans les noms des fichiers"
Ext = InputBox("Saisissez l'extension du fichier à rechercher Exemple ""vbs"" ou bien ""txt"" ou bien ""xls"" sans les guillemets",Titre,"txt")
If Ext = "" Then wscript.Quit
DebutMot = InputBox("Saisissez la chaîne de caractères qui débute avec le nom du fichier à rechercher :",Titre,"mon_fichier_")
If DebutMot = "" Then wscript.Quit
Set ws = CreateObject("wscript.shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Cmd = "cmd /c mode con cols=100 lines=2 & Color 90 & Title Veuillez Patientez... La Recherche du Mot """&DebutMot&""" dans les noms des fichiers de Type """&Ext&""" est en cours .............. & Dir c:\*."& Ext &" /s /b > c:\RechFich.txt"
Execution = ws.run(Cmd,1,True)
Set f = FSO.OpenTextFile("c:\RechFich.txt",ForReading)
sResults = sResults & f.ReadALL
sResults = Replace(sResults,"","é") 'Correction de l'ouput
Set fCorrection = FSO.OpenTextFile("c:\RechFich.txt",ForWriting,True)
fCorrection.Writeline sResults
fCorrection.close
Set objFiles = FSO.OpenTextFile("c:\FiltrerRechFich.txt",ForWriting,True)
Set objRegex = new RegExp
objRegex.Pattern = "(.w*)*"& DebutMot &"(.w*)*\."& Ext
objRegex.Global = True
objRegex.IgnoreCase = True
Set Matches = objRegex.Execute(sResults)
For Each Match in Matches
objFiles.Writeline Match.value
Next
MsgBox "La Recherche du Mot """&DebutMot&""" dans les noms des fichiers de Type """&Ext&""" est Terminé !",64,Titre
ws.Run "c:\FiltrerRechFich.txt",1,False |
Partager