Open dopus from python script

Sometimes I need to open a file's location from within my Python app.
This script will open the folder "music" and select "song.mp3" (but not play it), this is exactly the behaviour I want, but naturally, it opens windows explorer, I need it to open the default file manager, Dopus. Any help would be appreciated.

import subprocess
subprocess.Popen(r'explorer /select,"E:\music\song.mp3"')

Easiest solution: You could run an Opus-specific command instead of the Explorer-specific command.

Instead of running explorer /select,"E:\music\song.mp3", run this:

"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /open "E:\music\song.mp3"

An even better way might be to call an API which will open the default file manager. Then Explorer or Opus will open according to your Explorer Replacement settings, and you can share your script with other people without worrying about which file manager they use.

For reference, doing that with just a folder is easier than doing it with a folder + file (just call ShellExecute, or the language's equivalent, on the folder with null as the verb so it uses the default verb). But there is an API to do it with the file-in-folder case:

It looks like you can call that API from Python. I don't know enough Python to be able to judge which is the best thread / example, but some of these have code in them which looks like it should work:

https://www.google.com/search?q=SHOpenFolderAndSelectItems+Python

Thanks Leo,
I think the simplest approach would be to test if Dopus exists and if not revert to the explorer line.
Thanks for lighting the way :grinning:

I open folders in Python using os.startfile(r"C:\foldername") to open them with the file manager set by the Explorer Replacement settings.

Hi Robert,
Yes os.startfile was my first thought and it works fine for opening the folder but I couldn't figure out a way of making it highlight the particular file I was interested in. If I included the filename it would always open it with the default app, which is not what I want.
I am working with a folder containing several thousand files, for convenience I need the folder to open and the file to be selected.
If you have any other thoughts please let me know.
Thanks.