# Selecting files from a list?

**URL:** https://resource.dopus.com/t/selecting-files-from-a-list/16031
**Category:** Help & Support
**Created:** [July 22, 2013, 4:20pm UTC](https://resource.dopus.com/t/selecting-files-from-a-list/16031 "2013-07-22T16:20:35Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![MartO](https://resource.dopus.com/user_avatar/resource.dopus.com/marto/32/54727_2.png) [@MartO](https://resource.dopus.com/u/MartO)
#### Post date: [July 22, 2013, 4:20pm UTC](https://resource.dopus.com/t/selecting-files-from-a-list/16031/1 "2013-07-22T16:20:35Z")

</div>

Hi all,

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:

```
oExec = Shell.Exec("C:\path\to\dopusrt.exe /acmd SELECT EXACT myFile.mp3")

```

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?

Thanks a lot,  
MartO

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [July 22, 2013, 4:49pm UTC](https://resource.dopus.com/t/selecting-files-from-a-list/16031/2 "2013-07-22T16:49:14Z")

</div>

[ul][li]a) You could use the list and select modes of the recently added dopusrt.exe /info command. ([Retrieving File and Folder Information](http://gpsoft.com.au/help/opus10/default.htm#!Documents/Retrieving_File_and_Folder_Information.htm))  
  
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]

---

<div class="post-metadata">

### Author: ![MartO](https://resource.dopus.com/user_avatar/resource.dopus.com/marto/32/54727_2.png) [@MartO](https://resource.dopus.com/u/MartO)
#### Post date: [July 22, 2013, 5:07pm UTC](https://resource.dopus.com/t/selecting-files-from-a-list/16031/3 "2013-07-22T17:07:38Z")

</div>

Once again: Wow, you're fast!! 😃

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?

Thanks,  
MartO

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [July 22, 2013, 5:26pm UTC](https://resource.dopus.com/t/selecting-files-from-a-list/16031/4 "2013-07-22T17:26:26Z")

</div>

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.)

---

<div class="post-metadata">

### Author: ![MartO](https://resource.dopus.com/user_avatar/resource.dopus.com/marto/32/54727_2.png) [@MartO](https://resource.dopus.com/u/MartO)
#### Post date: [July 23, 2013, 4:48pm UTC](https://resource.dopus.com/t/selecting-files-from-a-list/16031/5 "2013-07-23T16:48:29Z")

</div>

Solved the (non-)mystery myself...

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

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [July 23, 2013, 4:54pm UTC](https://resource.dopus.com/t/selecting-files-from-a-list/16031/6 "2013-07-23T16:54:08Z")

</div>

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.)

---

<div class="post-metadata">

### Author: ![MartO](https://resource.dopus.com/user_avatar/resource.dopus.com/marto/32/54727_2.png) [@MartO](https://resource.dopus.com/u/MartO)
#### Post date: [July 23, 2013, 5:01pm UTC](https://resource.dopus.com/t/selecting-files-from-a-list/16031/7 "2013-07-23T17:01:28Z")

</div>

I did, thank you! [;)]
