Advertisement
Batchonline2

Untitled

Oct 3rd, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. <code de : @dm_4ever : http://www.visualbasicscript.com/How-to-make-a-multiple-file-selecting-hta-in-vbscript-Local-Filesystem-m62641.aspx. - Adapté par Sachadee for : batch.xoo.it http://batch.xoo.it/t4828-Broyeur-de-fichier-manuel.htm#p35674>
  2.  
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  6. <title>BROYEUR</title>
  7. <script language="vbscript">
  8. Option Explicit
  9.  
  10. Dim objFSO,objFile,outfile
  11.  
  12. outfile = "sortie.txt"
  13.  
  14. Set objFSO = CreateObject("Scripting.FileSystemObject")
  15. Set objFile = objFSO.CreateTextFile(outfile,True)
  16.  
  17. Sub MainGetFiles()
  18. Dim strRootPath : strRootPath = BrowseForFolder
  19.  
  20. window.document.getElementById("root_path").value = strRootPath
  21.  
  22. ClearFileList()
  23.  
  24. If strRootPath <> "" Then
  25. AddToFileList GetFiles(strRootPath)
  26. End If
  27. End Sub
  28.  
  29. Sub ClearFileList()
  30. Dim objFileList : Set objFileList = window.document.getElementById("folder_files")
  31. Dim intIndex
  32. For intIndex = objFileList.Length - 1 To 0 Step -1
  33. objFileList.Remove(intIndex)
  34. Next
  35. End Sub
  36.  
  37. Sub AddToFileList(dictFiles)
  38. Dim objFileList : Set objFileList = window.document.getElementById("folder_files")
  39. Dim strFilePath, objOption
  40. For Each strFilePath In dictFiles.Keys
  41. Set objOption = window.document.createElement("option")
  42. objOption.text = strFilePath
  43. objOption.value = strFilePath
  44.  
  45. objFileList.Add(objOption)
  46. Next
  47. End Sub
  48.  
  49. Function GetFiles(strPath)
  50. Dim dictFiles : Set dictFiles = CreateObject("Scripting.Dictionary")
  51. Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
  52.  
  53. If objFSO.FolderExists(strPath) Then
  54. Dim objFolder : Set objFolder = objFSO.GetFolder(strPath)
  55. Dim objFile
  56. For Each objFile In objFolder.Files
  57. dictFiles.Add objFile.Path, objFile.Name
  58. Next
  59. End If
  60.  
  61. Set GetFiles = dictFiles
  62. End Function
  63.  
  64. Sub SendSelectedFiles()
  65. Dim objOption
  66. For Each objOption In window.document.getElementById("folder_files").options
  67. If objOption.Selected Then
  68. objFile.Write objOption.Value & vbCrLf
  69. End If
  70. Next
  71. objFile.Close
  72. Self.Close
  73. End Sub
  74.  
  75.  
  76. Function BrowseForFolder
  77.  
  78. Const BIF_NEWDIALOGSTYLE = &H40
  79. Const ssfDRIVES = &H11
  80.  
  81. Dim objShell : Set objShell = CreateObject("Shell.Application")
  82. Dim objFolder : Set objFolder = objShell.BrowseForFolder(0, "Selectionnez le repertoire", BIF_NEWDIALOGSTYLE, ssfDRIVES)
  83.  
  84. If Not objFolder Is Nothing Then
  85. BrowseForFolder = objFolder.Self.Path
  86. Else
  87. BrowseForFolder = ""
  88. End If
  89. End Function
  90. </script>
  91. <hta:application
  92. applicationname="Test"
  93. border="dialog"
  94. borderstyle="normal"
  95. caption="Test"
  96. contextmenu="yes"
  97. icon=""
  98. maximizebutton="yes"
  99. minimizebutton="yes"
  100. navigable="no"
  101. scroll="no"
  102. selection="yes"
  103. showintaskbar="yes"
  104. singleinstance="yes"
  105. sysmenu="yes"
  106. version="1.0"
  107. windowstate="normal"
  108. >
  109. </head>
  110. <body>
  111. <div align="center"><h1>Test</h1></div>
  112. Repertoire:&nbsp;&nbsp;
  113. <input type="text" id="root_path" readonly size="50">&nbsp;&nbsp;
  114. <input type="button" value="Choisir le Dossier" onclick="MainGetFiles()">
  115. <br>
  116. <br>
  117. Selection des Fichiers:<br>
  118. <select id="folder_files" multiple size="10"></select>
  119. <br>
  120. <br>
  121. <input type="button" value="OK" onclick="SendSelectedFiles()">
  122. </body>
  123. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement