| 12
 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
 
 | Dim Folder2crawl(1)
Folder2crawl(0)="C:\Nouveau dossier\TEST"
Folder2crawl(1)="C:\Nouveau dossier\TEST2"
Dim str2write
 
strOutput = "C:\wamp\www\site1\index_output.json"
' create file object
Set oFSO = CreateObject("Scripting.FileSystemObject")
' create output file
Set Output = oFSO.CreateTextFile(strOutput, True)
 
str2write = "{""folder"": ["
' main loop
 
For i = 0 to UBound(Folder2crawl)
	strFolder = Folder2crawl(i)
	Set oFolder = oFSO.GetFolder(strFolder)
	' start new folder
	str2write =  str2write & "{""file"": ["
 
	Set colFiles = oFolder.Files
	For Each objFile In colFiles ' loop to write each file
	  	str2write = str2write & "{""name"": """ & Replace(objFile.Path,"\","\\") & """,""lastmodified"": """ & objFile.DateLastModified & """},"
	Next
	ShowSubFolders(oFolder) ' calls function for recursivity support
	str2write = str2write & "]},"
Next
' end main loop
 
str2write = str2write & "]}"
 
' function for recursivity support
Sub ShowSubFolders(oFolder)
  Set colFolders = oFolder.SubFolders
  For Each objSubFolder In colFolders
	Set colFiles = objSubFolder.Files
    For Each objFile In colFiles
	  str2write = str2write & "{""name"": """ & Replace(objFile.Path,"\","\\") & """,""lastmodified"": """ & objFile.DateLastModified & """},"
	Next
    ShowSubFolders(objSubFolder) ' calls function for recursivity support while subfolder exists
   Next
End Sub
 
Output.write(Replace(str2write,",]}","]}"))
' end of script - output file closure
Output.Close | 
Partager