[Tip] Paste a file or folder path to the command prompt quickly

There are times when you need to paste a file or folder path to the Windows command prompt. You might be doing several mouse clicks or typing for this simple task. It is possible to optimize this simple operation and reduce the amount of clicks.

In general, you may frequently need:

  • to copy the full path to a file using the Ribbon or context menu in File Explorer in Windows 8.
  • and to right click the command prompt's window title and choose Edit -> paste command from its context menu or right click the black input area and choose the Paste command from there. Even if you have "Quick Edit" mode, where a simple right click pastes the clipboard's contents, there is a faster way.

Not so many people seem to be aware that it is possible to drag the desired file or folder directly to the command prompt window to paste it's path into the command prompt. This is extremely handy if you need to paste the path of the several files or repeat this task for many objects one by one.

Just select some file or folder in File Explorer and drag it to the opened command prompt. In the example below, I did that with the "Program Files" folder:

cmd drag drop
As you can see from the screenshot above, the full path of that folder had been added to the command line. This works in Windows XP, Windows 7 and Windows 8/8.1 (but not Vista).

Note: In case the drag and drop to the Windows command prompt does not work, it may be because of the fact that you opened an elevated command prompt. Elevated command prompt runs at a higher integrity level and lower integrity processes can't communicate with it. In that case, you will not be able to drop files there from File Explorer. To get it working, you need to run your file manager app also elevated. In that case, you can use some alternative file manager tool, or make Windows File Explorer to run as administrator on Windows 8.1, Windows 8 and Windows 7.

3 thoughts on “[Tip] Paste a file or folder path to the command prompt quickly

  1. François

    Paste a file or folder path to the command prompt quickly ?
    Select the file you want to copy the fully qualified name,
    Ctrl-C (yes, exactly like if you are to copy the file),
    Alt-tab up to the command prompt window,
    Be sure that the mouse pointer is anywhere over the command prompt window,
    Right-click the mouse. (OK, this part is longer but to do it faster, just keep the mouse near the keyboard).

    Reply
    1. Chris

      This does not work, at least for me in Windows 10.

      Reply
  2. Chris

    Thank you for this post! Most simply say “it can’t be done”. Mysteriously, I was able to do this with an Administrator prompt on Win7, but it stubbornly won’t do so in Win10. Below is a keyboard workaround which is pretty fast, IF you have a keyboard with what’s known as the Context key, which causes the same behavior as a right-mouseclick (I think most keyboards have this by now). It is located between the right Windows key and right CTRL key.

    Have the file whose name you want to copy highlighted in an Explorer window (by single left-mouseclicking the name). Press Shift and while holding it, press the Context key, then release both Shift and Context, then press A. You can then paste into the new Win10 command prompt by pressing CTRL-V or right-mouseclicking.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.