How to copy the command prompt output directly to the Windows clipboard

The classic way of copying data from the command prompt is the following:

  1. right click on the command prompt window title and choose Edit -> Mark command
  2. select the text inside the command prompt using the mouse
  3. to copy the selected text, right click on the command prompt window title and choose Edit->Copy command (or just press Enter on the keyboard).

If you have Quick Edit Mode enabled, then you can skip step 1 and directly drag to select and press Enter.

In Windows Vista, Microsoft has added a new way, which is quite handy and does not require so many clicks - the clip command. The clip command can accept the output of any console tools and send it to the Windows clipboard. Let's look how it can used with the following simple example.

Let's copy to the clipboard, the output of the dir command, which prints the given directory listing into the console.


In the screenshot above, you can see the result of the dir command. Let's modify the command, and combine the dir command with the clip command. Enter the following:

dir | clip

Note that the middle vertical bar is not capital 'i' or small 'L', that character is called the vertical bar or pipe. It is located above the '\' key. Press Shift+\ to enter it.

The output of this combination at the console will be empty:

Why? Because all of the console output results are sent directly to the clipboard!

Run the Notepad application (or your favorite text editor) and press CTRL+V to paste. You will get the directory listing in there:


Bonus tip: specially for the dir command, you can specify the /b switch, which will strip out the additional info from the output but will keep only file names. Modify the command to make it look like this:

dir /b|clip

You will get the following output in the clipboard:

Bonus Tip: clip.exe also ships as part of Windows XP Professional x64 Edition, so you could copy the 32-bit EXE for clip.exe from C:\Windows\syswow64 to Windows XP 32-bit edition too.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

Leave a Reply

Your email address will not be published.

Exit mobile version
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.