Site icon Winhelponline

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.

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.
    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.

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.

Exit mobile version