Option Explicit Function OnInit(initData) initData.name = "Command_SelectFileFromTxt" initData.desc = "Select files from text file." initData.min_version = "11.7.1" initData.copyright = "2014 Albator V (Michiels Thomas)" initData.version = "v1.0" initData.default_enable = true initData.config.TextFile = "temp.txt" initData.config.ClearLog = false initData.config.LogError = false initData.config_desc = Dopus.Create.Map("TextFile", "Enter the name of the text file.", _ "ClearLog", "Clear log when starting command.", _ "LogError", "Display error messages in log.") End Function Function OnAddCommands(addCmdData) Dim cmd: Set cmd = addCmdData.AddCommand() cmd.name = "SelectFromTxt" cmd.method = "OnSelectFromTxt" cmd.desc = "Select files from text file" cmd.label = "SelectFromTxt" cmd.icon = "reselect" cmd.template = "NODESELECT/S" End Function Function OnSelectFromTxt(funcData) Dim fs: Set fs = CreateObject("Scripting.FileSystemObject") Dim txtFilename: txtFilename = script.config.TextFile Dim strCurrentPath: strCurrentPath = funcData.func.sourcetab.path Dim i, Line, CptVide, CptSel ' Clear log If script.config.ClearLog = True Then Dopus.clearOutput ' Test if txt file exist On Error Resume Next Dim fn: Set fn = fs.OpenTextFile(strCurrentPath & "\" & txtFilename, 1, false) If err.number > 0 Then Dopus.OutputString "Error : '" & txtFilename & "' file is not found in source folder" : Exit Function ' Count lines number in file Dim strData: strData = fs.OpenTextFile(strCurrentPath & "\" & txtFilename, 1).ReadAll Dim numLines: numLines = Split(strData, vbCrLf) Dim nbLines: nbLines = UBound(numLines) + 1 Dopus.OutputString "Info : " & nbLines & " lines in file '" & txtFilename & "'" ' Put files in command funcData.func.command.ClearFiles() If nbLines > 0 Then For i = 1 to nbLines Line = Trim(numLines(i - 1)) If Line <> "" Then If fs.FolderExists(strCurrentPath & "\" & Line) Or fs.FileExists(strCurrentPath & "\" & Line) Then funcData.func.command.AddFile(strCurrentPath & "\" & Line) CptSel = CptSel + 1 Else If script.config.LogError = True Then Dopus.OutputString "Error (line " & i & ") : '" & Line &"' item is not found in source folder" End if Else If script.config.LogError = True Then Dopus.OutputString "Error (line " & i & ") : Line is empty" CptVide = CptVide + 1 End If Next End If ' Look if argument exists and select files from command If funcData.func.args.got_arg.nodeselect = 0 Then funcData.func.command.RunCommand("Select FROMSCRIPT DESELECTNOMATCH") Else funcData.func.command.RunCommand("Select FROMSCRIPT") End If Dopus.OutputString "Info : " & CptSel & " of " & nbLines - CptVide & " files were selected" End Function