How to Open File or Folder Path from the Clipboard Using Shortcut

Sometimes we may need to copy a file or folder path from your email or chat window to the clipboard, and open the file or folder manually. Most people open the file or folder by launching the Run dialog, pasting the path from the Clipboard, and clicking OK.

paste path from clipboard to Run dialog

If your job involves doing this sort of task repeatedly, manually opening the Run dialog and pasting the path every time can be tedious. You can simplify this using a keyboard shortcut (hotkey) with the help of a small AutoHotKey (AHK) script.

How to Open the File or Folder Path from the Clipboard

The AHK script mentioned below reads the file or folder path saved in the clipboard, checks if the path is valid and if so, launches it.

AutoHotkey is a free, open-source scripting language for Windows that allows users to easily create small to complex scripts for all kinds of tasks such as form fillers, auto-clicking, macros, etc.

  1. Download AutoHotkey and install it.
  2. Right-click on the desktop, click New, and select AutoHotkey Script.
  3. Rename the script file New AutoHotkey Script.ahk to open_path_clipboard.ahk
  4. Right-click the file and choose Edit Script
  5. Remove all lines in the script and replace it with the following code:
    ^+o::openpathfromclipboard()
    
    openpathfromclipboard() {
    strpath = %Clipboard%
    strpath := StrReplace(strpath,"""")
    strpath := StrReplace(strpath,"'")
    If InStr(strpath, "%")
    {
    Transform, strpath, Deref, %strpath%
    }
    
    If FileExist(strpath)
    {
    Run, % strpath
    }
    }
  6. Save the file open_path_clipboard.ahk and close the editor.
  7. Double-click to run the script. It will show up in the notification area.
  8. Now, copy a file or folder path from your chat window, Command Prompt, or elsewhere to the Clipboard.
    copy path to clipboard from command prompt

    The path can be to a file or folder, and it can be in any of the formats listed below:
    C:\Windows\System32
    "C:\Windows"
    %AppData%
    %userprofile%\desktop
    '%systemroot%\system32'
    "%systemroot%\notepad.exe"
    C:\Windows\system32\cmd.exe
  9. Press Ctrl + Shift + o to launch the file or folder path stored on the Windows Clipboard. The file/folder will be launched in the same way as you launch it via the Run dialog or double-click on the item. If the path is a folder, it should open in File Explorer.

Script Customization

You can change the keyboard hotkey in the (1st line of the) script if you need it. Here are the modifiers.



  • !   {Alt}
  • +   {Shift}
  • ^   {Ctrl}
  • #   {Winkey}

For example, for Ctrl + Alt + Shift + O, you’d use ^!+o.

(For the full list of keys that you can send or intercept, see AutoHotkey SendInput documentation.)

Hope that helped you quickly open a file or folder path stored on the clipboard.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support, my reader. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

2 thoughts on “How to Open File or Folder Path from the Clipboard Using Shortcut”

  1. I have a file path with a command-line option, like so:

    C:\Daily\MyProgram.exe /open C:\Daily\Folder\Subfolder\file.html

    This file path opens perfectly when pasted into the Run dialog. It does not, however, open via your script. My file path appears to fall outside your list of acceptable formats. Is there a way to modify the script to accommodate my kind of path? Thanks.

    Reply
    • John, Try this:

      ^+o::openpathfromclipboard()
      
      openpathfromclipboard() {
      strpath = %Clipboard%
      strpath := StrReplace(strpath,"""")
      strpath := StrReplace(strpath,"'")
      If InStr(strpath, "%")
      {
          Transform, strpath, Deref, %strpath%
      }
      
      Run, % strpath
      }

      But it won’t validate if the file exists or not. Will try to execute anything from the clipboard.

Leave a Comment