Myth
Myth

Reputation: 1602

opening a parent folder and highlighting particular child in default file browser using python

I am using following code to open a folder in default file browser.

if os.name == 'mac':
  subprocess.call(('open', folderPath))
elif os.name == 'nt':
  subprocess.call(('start', folderPath))
elif os.name == 'posix':
  subprocess.call(('xdg-open', folderPath))

Now the problem is I want to highlight the child folder/file which was selected earlier. Is there any way to do it? If not for all, at least for nautilus?

Upvotes: 1

Views: 225

Answers (1)

Johannes Sasongko
Johannes Sasongko

Reputation: 4248

xdg-open doesn't support this, so it has to be done on a per-app basis. After poking around the Nautilus code, I don't think it has this feature either. So, yeah, you're pretty much out of luck.

For Windows Explorer, you can use

subprocess.call(("explorer", "/select,", file_path))

Upvotes: 2

Related Questions