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