I'm trying to select all files that are listed in an M3U playlist (or any other list file). Since I didn't find a simple command (or anybody elses solution) to do that, I wrote a script that reads the playlist and for each entry uses Shell.Exec to make such a call to dopusrt:
So if the playlist contains 50 songs, this will call dopusrt 50 times. This solution works - more or less; it's slow and it's not realiable. My questions:
a) Is there a better way to achieve this? Can I somehow pass a file list to the SELECT command?
b) Is it necessary to wait for dopusrt to finish (oExec.Status != 0) befor calling it with the next command?
c) Sometimes not all files get selected; a certain random element seems to be involved, though I have no idea why. How do I ensure the selection of all files?
It's a bit of a pain here since the script would have to parse the output of the list command to work out which IDs it needs to send the select command, but it should be more reliable. (Provided the directory is not changing simultaneously, which would invalidate the IDs.)
[/li]
[li]b) It should not be necessary to wait for dopusrt.exe /acmd to finish. dopusrt.exe /acmd and /cmd don't wait for the commands they run to finish anyway, so waiting for them doesn't change much, although it would avoid having lots of dopusrt.exe instances all running at once (but that would only be a problem with a huge number of files, I expect).
[/li]
[li]c) Is it different files each time you run the command on the same set of files, or always the same ones?[/li][/ul]
a) Interesting, hadn't seen that yet. You're right, though, it's a bit of a pain - but if it's more reliable, I'll give it a try.
And no, the directory is not changing.
b) OK, I'll leave the checking out then.
c) I've tried it again: My playlist contains 4 of the 10 files in the folder. It seems that every other time (!) I run the command, all 4 get selected; inbetween the results is completely random, selecting any 1, 2 or 3 of the files - or even none at all. Any idea what's going on?
c) That seems strange, and I can't think why it would happen off the top of my head.
If you want, send the script over (you'll probably need to zip it up for the forum to accept it) and I'll try running it when I have a moment. (Probably not today, as I'm finishing up some other work.)
The problem was that before parsing the playlist and calling dopusrt to select each individual mp3 I used another call to dopusrt for deselecting everything. I did not wait for this call to finish before continuing - and obviously it was sometimes very quick and sometimes lasted longer than the first few of my SELECT calls. This resulted in the files I had just selected being deselected again.
What have I learned? There's nothing synchronous about these calls to dopusrt; they even overtake each other... If my script relies on their results I need to wait for them to finish!
Thanks, leo, for the offer to test my script - there's no more need to bother you now!
Next I'll try the alternative method you described above!
Thanks,
MartO
In that case, if you're running the script from Opus, just put a "Select NONE" on the line before the script is run. That will be run synchronously before the line to run the script. (It's only things launched via dopusrt that are async, normally.)