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
| Const ForReading = 1,ForWriting = 2, ForAppending = 8
Dim ostRep 'Nom du repertoire a parcourir
Dim oFSO,oFl,of,f,objFSO,objFile
Dim strDirectory, strFile
Dim oLine,oMyArray,Chaine,oResultat
Set oFSO = CreateObject("Scripting.FileSystemObject")
ostRep = "c:\log"
If oFSO.FolderExists(ostRep) Then
For Each oFl In oFSO.GetFolder(ostRep).Files
'MsgBox oFl.Name
oFileName = oFl.Name
'Ouverture et lecture du fichier a modifier...
Set of = oFSO.OpenTextFile(ostRep & "\" & oFileName, ForReading)
While Not of.AtEndOfStream
oLine = of.ReadLine
'MsgBox oLine
If oLine = "" Then 'J' ai essayer ceci mais ca pas l' air de fonctionner
'Do nothing
Else
oMyArray = Split(oLine,"_")
'MsgBox oMyArray(1)
Chaine = oMyArray(1)
oResultat = Split(Chaine,".")
'MsgBox oResultat(0)
'MsgBox oResultat(1)
' Create the File System Object
strDirectory = "c:\Log"
strFile = "\NewLog.csv"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strDirectory & strFile) Then
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
ElseIf objFSO.FileExists(strDirectory & strFile) Then
Set f = objFSO.OpenTextFile(strDirectory & strFile, ForWriting,True)
f.write(oResultat(0) & ";" & oResultat(1))
f.Close
Else
MsgBox "Fichier inexistant"
End If
End If
'WScript.Quit
Wend
of.Close
Next
End If |
Partager