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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
| Function bandeRAZ(repFile)
Const ForReading = 1, ForWriting = 2
Dim oFs, oFile
Dim nbLgn
Set oFs = CreateObject("Scripting.FileSystemObject")
strSesFile = repFile
'FullPathFicIni = "P:\Scripts\band raz\traitement.ini"
Set ficSes = oFs.OpenTextFile(strSesFile, ForReading)
'récupération d'un tableau de x lignes totalité du fichier
ContenuLgnSes = split(ficSes.ReadAll,vbnewline)
'Récupère le nombre de ligne dans un fichier
nbLgnSes = ficSes.Line -1
'fermeture du fichier
ficSes.close
'Set ficIni = oFs.OpenTextFile(FullPathFicIni, ForReading)
'récupération d'un tableau de x lignes totalité du fichier
'ContenuLgnIni = split(ficIni.ReadAll,vbnewline)
'Récupère le nombre de ligne dans un fichier
'nbLgnIni = ficIni.Line -1
'fermeture du fichier
'ficIni.close
'Initialisation de la variable f
set ficSes = nothing
End Function
Function traitementSection(rechercheLang)
Const ForReading = 1, ForWriting = 2
Dim oFs, oFile
Dim nbLgn
Set oFs = CreateObject("Scripting.FileSystemObject")
Dim strIniFile
lang = rechercheLang
'Emplacement du fichier traitement.ini
strIniFile="P:\Scripts\band raz\traitement.ini"
Set oFs=CreateObject("Scripting.FileSystemObject")
'Ouverture et lecture de traitement.ini
Set oFile=oFs.OpenTextFile(StrIniFile)
'récupération d'un tableau de x lignes totalité du fichier
ContenuLgn = split(oFile.ReadAll,vbnewline)
'Récupère le nombre de ligne dans un fichier
nbLgn = oFile.Line -1
'Fermeture du fichier ini
oFile.close
for t = 0 to nbLgn
debSection = left(ContenuLgn(t),"=")
if debSection = "[" & lang & "]" then
test = debSection
msgbox test
exit for
end if
next
End Function
Function typeLang(t)
Dim strIniFile
'Emplacement du fichier traitement.ini
strIniFile="P:\Scripts\band raz\traitement.ini"
Set oFs=CreateObject("Scripting.FileSystemObject")
If oFs.FileExists(strIniFile) Then
set resultLang = Nothing
'Ouverture et lecture de traitement.ini
Set oFile=oFs.OpenTextFile(StrIniFile)
'récupération d'un tableau de x lignes totalité du fichier
ContenuLgn = split(oFile.ReadAll,vbnewline)
'Récupère le nombre de ligne dans un fichier
'nbLgn = oFile.Line -1
'Fermeture du fichier ini
oFile.close
'lecture du tableau contenant le contenu du fichier traitement.ini
for t = 1 to traitementIni(nbreLgn)
'Récupérer les 2 première lettres de chaque variable dans le fichier ini
resultLang = replace(ContenuLgn(t),left(ContenuLgn(t),5),"")
traitementSection(resultLang)
'msgbox lang
next
Else
Msgbox "Le dossier (.ini) n'a pas été trouvé"
WScript.Quit
End If
typeLang = resultLang
Set oFile=Nothing
Set oFs=Nothing ' Si l'on ne s'en sert plus
End Function
Function listerFichiers(repFichiers)
Dim fichiersRep 'Nom du répertoire à parcourir
Dim oFs,oFl
Dim name, nameFolder
Set oFs = CreateObject("Scripting.FileSystemObject")
fichiersRep = repFichiers
If oFs.FolderExists(fichiersRep) Then
'lister les fichiers d'un dossier
For each oFl in oFs.GetFolder(fichiersRep).Files
name = oFl.Name
nameFolder = fichiersRep & "\" & name
bandeRAZ(nameFolder)
'msgbox nameFolder
'msgbox name
'typelang()
Next
End If
'retourne le resultat de la fonction
listerFichiers = nameFolder
End Function
Function numKids(pathDossier)
Dim oFs, FicIni
Dim strDebug
Set oFs = CreateObject("Scripting.FileSystemObject")
FullPathFicIni = "P:\Scripts\band raz\traitement.ini"
If oFs.fileExists(FullPathFicIni) Then
Set FicIni = oFs.opentextfile(FullPathFicIni)
'récupération d'un tableau de x lignes totalité du fichier
ContenuLgn = split(FicIni.ReadAll,vbnewline)
'Récupère le nombre de ligne dans un fichier
'nbLgn = FicIni.Line -1
'Fermeture du fichier ini
FicIni.close
for t = 1 to traitementIni(nbreLgn)
'lectureSection = ContenuLgn(t)
dossier = replace(ContenuLgn(t),right(ContenuLgn(t),3),"")
if oFs.FolderExists("P:\Scripts\band raz\Reception\" & dossier) Then
resultDossier = "P:\Scripts\band raz\Reception\" & dossier
'Appel de la fonction permettant de lister les fichiers dans chaque répertoire
listerFichiers(resultDossier)
Else
msgbox "le répertoire " & dossier & " n'existe pas"
End if
next
Else
Msgbox "Le dossier (.ini) n'a pas été trouvé"
WScript.Quit
End If
End Function
Function traitementIni(nbreLgn)
Dim oFs, FicIni
Dim strDebug
Set oFs = CreateObject("Scripting.FileSystemObject")
FullPathFicIni = "P:\Scripts\band raz\traitement.ini"
Set FicIni = oFs.opentextfile(FullPathFicIni)
'récupération d'un tableau de x lignes totalité du fichier
ContenuLgn = split(FicIni.ReadAll,vbnewline)
'Récupère le nombre de ligne dans un fichier
nbLgn = FicIni.Line -1
'Fermeture du fichier ini
FicIni.close
'lecture du tableau contenant le contenu du fichier traitement.ini
for t = 0 to nbLgn
'sectionDeb = Left(ContenuLgn(t), 9)
sectionFin = Left(ContenuLgn(t),10)
nbre = nbre + 1
'tant que la section [/Langage] n'est pas passé, on increment nbre de 1
if sectionFin = "[/Langage]" Then
nbreLgn = nbre - 2
exit for
end if
next
'retourne le resultat de la fonction
traitementIni = nbreLgn
End Function
'numKids(debTraitement)
typeLang(g)
'test( |
Partager