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
| '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
Set obFolder2 = obFolder
If Not obfolder IS Nothing Then 'si obfolder n'est pas rien!
'Corps du script
'Start WellCAD
Set WCAD = CreateObject("WellCAD.Application")
WCAD.ShowWindow()
'Get access to input folder and process it
'Crée la variable PATH comme étant le chemin du répertoire du script
PATH = FSO.GetParentFolderName(wscript.ScriptFullName) & "\"
'wscript.echo "Path = " & PATH
'Appel le sous programme Processfolder
Processfolder WCAD, FSO, PATH, obFolder.self.Path
MsgBox "Finished"
Else
MsgBox "Canceled"
End If
'Sous Programme process folder
Sub ProcessFolder(WCAD, FSO, PATH, FolderPath)
'Get access to the folder
Set obFolder = FSO.GetFolder(FolderPath)
'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
If (StrComp(Right(obFile.Name, 3), "las", 1) = 0) Then ProcessLasFiles WCAD, FSO, FolderPath
Exit For
'End If
Next
'Loop on all the subfolders and process each of them
For Each obSubFolder In obFolder.SubFolders
ProcessFolder WCAD, FSO, PATH, obSubFolder.Path
Next
End Sub
Sub ProcessLasFiles (WCAD, FSO, FolderPath)
Wscript.echo "Trouvé fichier LAS"
Set obSubFolder = FSO.GetFolder(FolderPath)
Wscript.echo "obSubFolder = " & obSubFolder 'contient bien le bon chemin
End Sub |
Partager