Rechercher de tous les fichiers d'un répertoire donné
Bonjour à tous, je dois ajouter un suffixe à chaque ligne de fichier texte. Sur un fichier, je sais le faire, mais je ne sais pas comment choisir tous les fichiers *.txt d'un répertoire donné.
Code:
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
| Path = "C:\TEST"
const ficlu = "azerty.txt"
const ficecrit = "nouveau.txt"
const carac = ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1" ' caractère à mettre en bout de ligne
Set oFso = CreateObject("Scripting.FileSystemObject")
if not ofso.fileexists(ficlu) then _
msgbox "fichier non trouvé",, ficlu : wscript.quit
Const ForReading = 1
const ForWriting = 2
Const TristateTrue = -1 ' Unicode
Set fs = oFso.OpenTextFile(ficecrit,ForWriting,true)
fic= oFSO.GetFile(ficlu).path
Set fl = oFso.OpenTextFile(fic,ForReading, TristateTrue)
while Not fl.AtEndOfStream
lig = fl.readline
fs.writeline (lig & carac)
Wend
fl.Close : fs.close
' renommer les fichiers
f= left(ficlu,len(ficlu)-3) & "bak"
ofso.movefile ficlu, f
ofso.movefile ficecrit, ficlu |
Si quelqu'un peut me donner un peu d'aide...
D'avance, merci.