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
| 'Get Application object of the Windows shell.
Set objShell = WScript.CreateObject("Shell.Application")
'Get access to script folder And create the resulting file in it
Set FSO = CreateObject("Scripting.FileSystemObject")
PATH = FSO.GetParentFolderName(wscript.ScriptFullName) & "\"
'Ask the user to select a folder
Set obFolder = objShell.BrowseForFolder (&H0&, "Select the folder to process", &H1&)
'Keep obFolder for Sub programms
If Not obfolder IS Nothing Then 'si obfolder n'est pas rien!
'Wscript.echo "Repertoire : " & obFolder
'Wscript.echo "Ici on bosse!"
'Recherche des fichiez *.kml
ProcessFolder FSO, PATH, obFolder.self.Path
MsgBox "Finished"
Else
MsgBox "Canceled"
End If
Sub ProcessFolder(FSO, PATH, FolderPath)
'Wscript.echo "ob Folder (ligne 122) = " & obfolder
'Get access to the folder
Set obFolder = FSO.GetFolder(FolderPath)
Dim FileName 'Déclarer la variable permet de l'utiliser dans les différents sous programmes
Dim Chemin
Dim CheminFichier
'Loop on all the files And process each of them
For Each obFile In obFolder.Files
'Regarde si fichiers présent dans le répertoire
'FileName = obFile.Name
Chemin = obFolder & "\"
'Wscript.echo "1 Le chemin est : " & Chemin
CheminFichier = obFolder & "\" & obFile.Name
'Wscript.echo "1 Le chemin du fichier est : " & CheminFichier
'Wscript.echo "1 Le nom du fichier est : " & obFile.Name
If (StrComp(Right(obFile.Name, 4), ".kml", 1) = 0) THEN
'Constant for reading & writting files
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8 'pour ajouter à la fin
Wscript.echo "2 Le chemin du fichier est : " & obFile.Path
FSO.GetFile (obFile)
Set RL = FSO.OpenTextFile(obFile, ForReading, True)
'RL = FSO.OpenTextFile(obFolder & "\" & obFile.Name, ForReading, True)
Lignelue = Rl.ReadLine
End If
Next
'Loop on all the subfolders And process each of them
'For Each obSubFolder In obFolder.SubFolders
' ProcessFolder FSO, PATH, obSubFolder.Path
'Next
End Sub |
Partager