Select files from txt file

Select files from txt file

At job, I need to select files from temp.txt file.

I don't think it's possible to do this directly with DOpus so I create a button with a vb script.

Problem is that I don't understand why some files are not selected.
I think about async problem but...

You can find folders.txt (create these folders), temp.txt (put it in the same directory) and button.txt (copy text in toolbar).
Click button and look that some folders are not selected (you can see some details in log panel).
button.txt (6.07 KB)
folders.txt (1.61 KB)
temp.txt (1.03 KB)

I think you just need to change
Shell.Run strCommand,0,false
to
Shell.Run strCommand,0,true

But while working that out, I also made some other improvements, so here's the button/script with them, which seems to work here at least:

Rename FROM . TO .

@script vbscript
Option Explicit
Dim DOpusRTPath
DOpusRTPath = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe"
Dim Shell
Set Shell = CreateObject("WScript.Shell")

' Sélectionner des fichiers et dossiers listés dans un fichier temp.txt

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

Dim txtFilename
txtFilename = "temp.txt" ' Name of the file that contain files to select

Dim flag
flag = 0 ' 0 = not initialized, 1 = initialized, 2 = filenames file not found, 3 = clipboard file not found either

Dim cptError
cptError = 0

Dopus.OutputString "Nom du Script : Sélectionner des fichiers ou dossiers à partir d'un temp.txt - Ecrit par Albator V"

Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)
Dim i, fn, arrLines, LineCount, strData, Line, SrcFolder, DestFolder, strCommand

' Set strNewName to an empty string so that Opus does not rename the file.
strNewName = ""

' Open file containing folder list to select
If flag = 0 Then
	on error resume next
	Set fn = fs.OpenTextFile(strFilePath & "\" & strFileName & "\" & txtFilename, 1, false)
	If err.number > 0 Then flag = 2 Else flag = 1
	If flag = 2 Then
		Dopus.OutputString "Erreur : Pas de fichier '" & txtFilename & "' dans le dossier source."
	End if
End if

' Try to find alternate file (clipboard output file)
If flag = 2 Then
	on error resume next
	Set fn = fs.OpenTextFile(strFilePath & "\" & strFileName & "\Texte du presse-papiers.txt", 1, false)
	If err.number > 0 Then flag = 3 Else flag = 1
	If flag = 1 Then
		Dopus.OutputString "Info : Un fichier 'Texte du presse-papiers.txt' se trouve dans le dossier source."
		Dopus.OutputString "Info : Ce fichier sera utilisé pour sélectinner les éléments."
		txtFilename = "Texte du presse-papiers.txt"
		Msgbox "Un fichier '" & txtFilename & "' se trouve dans le dossier source." & vbcr & "Il sera utilisé pour sélectionner les éléments à la place du fichier 'temp.txt'.", vbexclamation
	End if
	If flag = 3 Then
		Dopus.OutputString "Erreur : Pas de fichier 'Texte du presse-papiers.txt' dans le dossier source."
		Dopus.OutputString "Erreur : Aucun dossier n'a été sélectionné."
		Msgbox "Il y a ni fichier 'temp.txt' ni fichier 'Texte du presse-papiers.txt' dans le dossier source." & vbcr & vbcr & "Aucun dossier n'a été sélectionné.", vbexclamation
		Exit Function
	End if
End if

' Count lines number in file

strData = fs.OpenTextFile(strFilePath & "\" & strFileName & "\" & txtFilename, 1).ReadAll
arrLines = Split(strData, vbCrLf)
LineCount = UBound(arrLines) ' + 1
Dopus.OutputString "Nombre de ligne total :" & LineCount

' Select files
If ubound(arrLines) > 0 Then
	For i = lbound(arrLines) to ubound(arrLines)
		Line = Trim(arrLines(i))
		SrcFolder = Line
		 Dopus.OutputString "Ligne du fichier: " & Line

		If Line <> "" Then
			strCommand = """" & DOpusRTPath & """ /cmd Select EXACT """ & SrcFolder & """"
		    	 Dopus.OutputString "Commande à executer: " & strCommand
		    	Shell.Run strCommand,0,true
		End If
	Next
End If

If cptError > 0 and cptError = LineCount Then Dopus.OutputString "Info : Tous les dossiers de la liste ont été déplacés dans le dossier de destination."

End Function

Excellent, many thanks Leo