pythonwindowsexplorer

Open explorer on a file


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.


Solution

  • From Geoff Chappell's The Windows Explorer Command Line

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