Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
- <title>BROYEUR</title>
- <script language="vbscript">
- Option Explicit
- Dim objFSO,objFile,outfile
- outfile = "sortie.txt"
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objFile = objFSO.CreateTextFile(outfile,True)
- Sub MainGetFiles()
- Dim strRootPath : strRootPath = BrowseForFolder
- window.document.getElementById("root_path").value = strRootPath
- ClearFileList()
- If strRootPath <> "" Then
- AddToFileList GetFiles(strRootPath)
- End If
- End Sub
- Sub ClearFileList()
- Dim objFileList : Set objFileList = window.document.getElementById("folder_files")
- Dim intIndex
- For intIndex = objFileList.Length - 1 To 0 Step -1
- objFileList.Remove(intIndex)
- Next
- End Sub
- Sub AddToFileList(dictFiles)
- Dim objFileList : Set objFileList = window.document.getElementById("folder_files")
- Dim strFilePath, objOption
- For Each strFilePath In dictFiles.Keys
- Set objOption = window.document.createElement("option")
- objOption.text = strFilePath
- objOption.value = strFilePath
- objFileList.Add(objOption)
- Next
- End Sub
- Function GetFiles(strPath)
- Dim dictFiles : Set dictFiles = CreateObject("Scripting.Dictionary")
- Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FolderExists(strPath) Then
- Dim objFolder : Set objFolder = objFSO.GetFolder(strPath)
- Dim objFile
- For Each objFile In objFolder.Files
- dictFiles.Add objFile.Path, objFile.Name
- Next
- End If
- Set GetFiles = dictFiles
- End Function
- Sub SendSelectedFiles()
- Dim objOption
- For Each objOption In window.document.getElementById("folder_files").options
- If objOption.Selected Then
- objFile.Write objOption.Value & vbCrLf
- End If
- Next
- objFile.Close
- Self.Close
- End Sub
- Function BrowseForFolder
- Const BIF_NEWDIALOGSTYLE = &H40
- Const ssfDRIVES = &H11
- Dim objShell : Set objShell = CreateObject("Shell.Application")
- Dim objFolder : Set objFolder = objShell.BrowseForFolder(0, "Selectionnez le repertoire", BIF_NEWDIALOGSTYLE, ssfDRIVES)
- If Not objFolder Is Nothing Then
- BrowseForFolder = objFolder.Self.Path
- Else
- BrowseForFolder = ""
- End If
- End Function
- </script>
- <hta:application
- applicationname="Test"
- border="dialog"
- borderstyle="normal"
- caption="Test"
- contextmenu="yes"
- icon=""
- maximizebutton="yes"
- minimizebutton="yes"
- navigable="no"
- scroll="no"
- selection="yes"
- showintaskbar="yes"
- singleinstance="yes"
- sysmenu="yes"
- version="1.0"
- windowstate="normal"
- >
- </head>
- <body>
- <div align="center"><h1>Test</h1></div>
- Repertoire:
- <input type="text" id="root_path" readonly size="50">
- <input type="button" value="Choisir le Dossier" onclick="MainGetFiles()">
- <br>
- <br>
- Selection des Fichiers:<br>
- <select id="folder_files" multiple size="10"></select>
- <br>
- <br>
- <input type="button" value="OK" onclick="SendSelectedFiles()">
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement