Skip to content

Instantly share code, notes, and snippets.

@MattWoodhead
Created June 25, 2017 14:21
Show Gist options
  • Save MattWoodhead/8acd76c7bda55031e12b8cf3ceeb7c3b to your computer and use it in GitHub Desktop.
Save MattWoodhead/8acd76c7bda55031e12b8cf3ceeb7c3b to your computer and use it in GitHub Desktop.
Open windows explorer with a specific folder or file selected
import subprocess
def explorer_on_file(url):
""" opens a windows explorer window """
subprocess.Popen(f'explorer /select,"{url}"')
explorer_on_file(r"C:\Python\python.exe")
@dan-e-lk
Copy link

dan-e-lk commented Nov 6, 2024

awesome. this not only opens the windows explorer at the right folder, but also selects the file specified. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment