2

How can I open Finder.app (on macOS), explorer.exe (on Windows), Gnome or similar (user's choice? on Linux) into a folder with a file highlighted using Python.

In macOS terminal

open -R /path/to/file

reveals the file in Finder.

In Windows

explorer /select,"C:\path\to\file"

seems to do the same thing.

What's the most reliable cross-platform implementation that is available in Python?

theonlygusti
  • 11,032
  • 11
  • 64
  • 119
  • Does this answer your question? [Is there an platform independent equivalent of os.startfile()?](https://stackoverflow.com/questions/17317219/is-there-an-platform-independent-equivalent-of-os-startfile) – Marat Nov 02 '21 at 20:29
  • @Marat it's a different question, but the top answer is helpful. Didn't know I only had to check `sys.platform` against win32 and darwin – theonlygusti Nov 02 '21 at 20:31
  • @Marat xdg-open doesn't seem to have a reveal-file option? – theonlygusti Nov 02 '21 at 20:34
  • as far as I know, it doesn't. – Marat Nov 02 '21 at 20:41

0 Answers0