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
| Dim Path : Path = Browse4Folder()
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim Files : Set Files = CreateObject("System.Collections.ArrayList")
Dim OrigTabCount : OrigTabCount = UBound(Split(Path, "\"))
Dim ws : Set ws = CreateObject("wscript.shell")
RecurseFolderFiles objFSO.GetFolder(Path)
ws.run "Tree.txt"
'*********************************************************************
Private Sub RecurseFolderFiles(objFolder)
Dim File, SubFolder
Dim TabCount : TabCount = UBound(Split(objFolder, "\")) - OrigTabCount
Dim Tabs
If TabCount > 0 Then
For i = 0 To TabCount
Tabs = Tabs & vbTab
Next
End If
WriteFile Tabs & "Dossier : " & objFolder.Name, "Tree.txt"
For Each File In objFolder.Files
WriteFile Tabs & vbTab & "Fichier : " & File.Name, "Tree.txt"
Next
For Each SubFolder In objFolder.SubFolders
RecurseFolderFiles SubFolder
Next
End Sub
'*********************************************************************
Sub WriteFile(strLine,fileName)
On Error Resume Next
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Do Until IsObject(objFile)
Set objFile = objFSO.OpenTextFile(fileName,8,True)
Loop
objFile.WriteLine strLine
objFile.Close
End Sub
'*********************************************************************
Function Browse4Folder()
Dim objShell,objFolder,Message
Message = "Please select a folder "
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0,Message,0,0)
If objFolder Is Nothing Then
Wscript.Quit
End If
Browse4Folder = objFolder.self.path
End Function
'********************************************************************* |
Partager