Open explorer on a file

Kirill Titov picture Kirill Titov · Nov 11, 2008 · Viewed 90.2k times · Source

In Python, how do I jump to a file in the Windows Explorer? I found a solution for jumping to folders:

import subprocess
subprocess.Popen('explorer "C:\path\of\folder"')

but I have no solution for files.

Answer

Blair Conrad picture Blair Conrad · Nov 11, 2008

From Geoff Chappell's The Windows Explorer Command Line

import subprocess
subprocess.Popen(r'explorer /select,"C:\path\of\folder\file"')