List To MultiInstance aka L2M

version 1.5	-	15.08.2003

Freeware for any purposes. AS IS.

Program was developed as Total Commander add-on, but can work as standart 
application.


!!!!

By First. Sorry for my English. My native languages is Russian & Pascal =)


PROBLEM AND SOLVE

Frequently there is a need to start the program and to pass to  the program as 
parameters some files. Many programs can open some files (MDI-application) or 
start self copies for each file (SDI-application). But count of programs, which 
can correctly process a set of files passed to it in the command line, is very 
few. Usually a program only open first file in command line, all other files are 
rejected, or names of all passed files is considered as continuation of a name 
of first file. 

So, for example, next command will start the Notebook for file "1.txt":

  notepad.exe "1.txt" "2.txt" "3.txt"

The following command will start a notebook for a file "1.txt 2.txt 3.txt":

  notepad.exe 1.txt 2.txt 3.txt

Some programs (for example, the Russian antiviruses AVP and DrWeb) can accept a 
name of a file, which include the list of the necessary files. Such programs 
execute necessary operations for each file in the list. Total Commander is able 
to create such files and to pass them as parameters (more about it look in Total 
Commander  help files). Total Commander put in the list-file selected files (or 
file under cursor if nothing is selected).

Respectively, if the program does not accept as parameter the list-file, You 
have to start it for each file manually. More correctly it was necessary 
earlier. Now you have "List To MultiInstance"

How It Work?

You pass to lst2mlt.exe a filename of program which you want to start parameter 
(optional) and filename of list-file, which include filenames of files needed to 
open. You also can pass some additional parameters.

Usage Syntax:

  lst2mlt [/X:<exe-file>] [/B:<b-params>] /L:<filelist> [/E:<e-params>] 
	[/F:<milliseconds>] [/S] [/W] [/P]

  <Exe file> - Program which will be started for each file in file-list. If <exe 
	file> absent then will be started program, default for file in list.

  <List-file> - list of files which will be opened

  <B-Params> - string (parameters), which will be inserted before name of file 
	from <list-file> before this command will be execute. May be absent.       

  <E-Params> - string (parameters), which will be inserted after name of file 
	from <list-file> before this command will be execute. May be absent.

  <milliseconds> - If this parameter is present L2M make pause of <milliseconds> 
	 before open second file. <milliseconds> may be equals zero. If /P key also 
	present /F-key ignored. Default pause is 1 second (see also "WinAMP playlist")
  
  /W - if this parameter is present, L2M not wait while executing program open 
	the file. By default, L2M wait. May be absent.   

  /S - switch method of execute program to alternative. (If you are want to 
	know, first method is use CreateProcess function and second - ShellExecuteEx 
	function)

  /P - if this key is present, L2M wait while previous opened file will be 
	closed. You can skip waiting process for file by "Skip" button in main dialog.
  (see also "MDI Application and /P")
  

lst2mlt.exe starts for each file from <List-file> the program  <Exe file>, pass 
it and <b-params> & <e-params> as parameter. 

During working process of L2M Dialog Window is showing. In this dialog you can 
see progress of opening files from list and can skip open current file and 
cancel whole opening process.

For example. 

Let "list-file.txt" content is:
   c:\1.txt
   c:\2.txt
   c:\autoexec.bat

And you enter such command in RunDialog or MS-DOS Prompt or in WindowsCommander, 
Far etc:

 lst2mlt.exe /X:notepad.exe /L:list-file.txt

After you press "Enter" "List To MultiInstance" execute this commands:

	notepad.exe c:\1.txt

then 

	notepad.exe c:\2.txt

and finally 
	notapad.exe c:\autoexec.bat

Now you have 3 Notepad with opened files in its. Enjoy =)

Well, I think what it is possible  to receive the best results and pleasure only 
having attached this programs to Total Commander. 


HOW TO ATTACH TO TOTAL COMMANDER? 

Create menuitem of Start-menu or Toolbar button and specify so: 

The command: <Path to lst2mlt>\lst2mlt.exe 
Parameters: /X:"<Path to exe file>" /L:"%L"

So, for example, for EditPlus2 on my computer the command look so: 

The command: c:\wincmd\lst2mult.exe 
Parameters: /X:"C:\Program Files\EditPlus 2\editplus.exe" /L:"%L" 

Instead of %L you can use %l, %F, %f, %D, %d.  Look Help if Total Commander. 
Now select files and run created menu- or toolbar- command.

Enjoy =). It's Free =). And only for you =)


PRE- AND POST- PARAMETERS.

If program which open file from list can parse addition parameters passed from 
command line, you can add its to L2M parameters and its has been added to each 
file in list. Some program require parameters before file name, another - after 
filename and another don't make differences. List To MultiInstance allow use any 
way fro pass parameters.

For example, NullSoft WinAmp allow enqueue file passed to it and dont play file 
immediately. To do this you must set "Enqueue as default action" in WinAmp 
settings. But let you don't want to set default action as Enqueue. Then you can 
add file to enqueue by command like:

	winamp.exe /ADD <path to mp3-file>

If you want add many files to winamp playlist you can use L2M aby command like 
(in Total Commander):

	/B:/ADD /L:"%L" /X:"C:\Program Files\Winamp\winamp.exe" /W


NOTES.

Drag&Drop in Total Commander (at present time - v5.51)

Many users make button on Total Commader toolbar to lunch favorite program. It's 
posible to drag file on this button to lunch assotiated program and pass dragged 
file to it. But this method have some limits. By the first, Total Commander pass 
only one file to program even if you select some files. By the second, all 
parameters is ignored - only program and filename as parameters. This is feature 
of Total Commander.

What is why if you drag and drop filename on button, which execute List To 
MultiInstance, no parameters /X and /L (and other of course) has been passed. In 
this case L2M execute program associated with extension of passed file.


WinAmp Playlist.

WinAmp is slick. For example, if you lunch mp3-file, then WimAmp clear current 
playlist and create new one. In this playlist it add you mp3 file. If you wait 
one or two second and repeat mp3 file lunching procedure , then situation will 
repeat too - new palylist and single file in it.

But if you lunch mp3 files very fast and dont make pause between lunches, then 
WinAmp also create new playlist after lunch first file, but lunching next files 
don't clear this playlist and all next files will be added to one playlist.

Before version 1.5 List To MultiInstance always make pause in one second after 
lunch first file to give program time to execute. This behaviour is conduce to 
situation when firs file didn't added to playlist =(.

Sinec v1.5 you can set pause between first and second file lunching by passing 
/F key. You have to select pause value which allow to start Winamp, but not 
allow lose first file in play list. If you have new powerful computer you can 
try to pass /F:0


MDI-application and /P key.

MDI (Multi Document Interface) application open all files inside one process, 
but SDI (Single Document Interface) open ech fiel in new process. For example, 
Adobe Photoshop - MDI application, but MSPaint - SDI Application.

The /P key tell List To MultiInstance to wait while previous opened file will be 
closed, but with MDI Application we have problem. To understand why we have 
problem, we must know how MDI apllication open files.

It's simple. When you lunch some file, windows execute application associated 
with file extencion and pass your file as parameter. SDI application just open 
passed file. True MDI application seek already executed self copy and , if 
found, send message to the copy. Messsage contain filename to open. After this 
new started MDI application close, and previous copy is open passed file.
If MDI appliction don't found self copy then it open file itself

When L2M lunch application, Windows return application handle by which L2M wait 
for application terminate (if /P key present, of course). 

If MDI application found self copy, then it close immediately and L2M receve 
message what application terminated and L2M lunch next file. In other words, L2M 
wait when application close, but not when file close.

For right work L2M with  MDI apllications and /P key please always close 
application - don't use Skip button. In other case all files will be opened 
without pauses (like /P key is absent). Pause will be only between first and 
second files.


List To MultiInstance, Copyright  2001-2003 by Tir Na Nog, All right reserved.
WWW:    http://tirna.narod.ru
E-Mail: mailto:tirna@narod.ru