22 March 2016

How to Copy Text From Windows Command Prompt

Leave a Comment
Command prompt is the soul of Windows operating system. If you're a programmer, you may know it very well that how much important it is. There are tons of commands which can do almost anything with your computer. Sometimes you may need to copy the text from cmd window but there is no direct option to do this as like we can do in case of copying text from other editors.

Copy Text From CMD

In other words, you can't select, copy, cut and paste anything directly in command prompt. Then how to do it? Fortunately, Windows provide another methods which can troubleshoot this problem. In this short tutorial, I will guide you how to do that. There are two different methods you can try. Let's start with first one.

1. Using CMD Edit Options

Command prompt provides manual edit options using which you can select, copy and paste any text easily. Normally, we right-click on text to perform these task but in case of command prompt, these features are hidden. So here I will tell you how to find and use them. Follow these step by step instructions.
  1. First of all, open cmd.exe from start menu.
  2. Now when you want to copy the text, right-click on program title.
  3. A hidden menu will open. Here click on "Edit" option and then click "Mark" button.

    Command Prompt

  4. Now select the text that you want to copy as like you select other text in editors. Alternatively, you can use "Select All" button. This will change the background color of cmd from black to white color which will highlight the selected area.
  5. After this, go back to the edit option and click "Copy" button.

    Copy Command Prompt Output

  6. Finally open your favorite editor, say I choose Notepad and paste all text inside it.

    Paste Text in Notepad
In this way, you can copy any desired text from Windows command prompt shell. There are few more task which you can do. For example, you can paste any text inside cmd or you can search for any word etc., I think you don't need any explanation for them. Try it yourself.

2. Using Clip Command

This method is quite different from first one. Here we will use clip command. Before moving further, let me tell you about clip. It simply redirects the output of command line tool to the Windows clipboard which can be later pasted in other programs also.

One more important thing is that, it copies single command output only. You can't use it to copy complete text of cmd as like you can do in first method. The basic syntax of clip command is - "Your command here | CLIP"

Clip Command

For example, SET /? | CLIP

This will copy all output of "Set /?" code. Actually when you'll add "/?" symbol after any command then it will display the help information. In the same way, above code will automatically copy all help information of set command. Few other examples are as follows -

  • DIR | CLIP - Display a list of all files and sub-directories of a particular directory.
  • HELP | CLIP - This will copy all cmd help information.
  • TREE C:\ | CLIP - Display the graphical structure of your C drive folders.
  • ECHO Hello | CLIP - This will simply copy "Hello" word.
After executing this clip command, go to your favorite editor, paste all text inside it and finally save it for future reference.

Additional Tip: There is another amazing use if clip command. You can also use it to copy text from any files. For example, if you've a txt file then clip command can copy all of its text. The basic syntax is -

CLIP < C:\Users\Username\Desktop\README.TXT

Above code will copy all text from readme.txt file to windows clipboard. Note that, this readme file is saved on desktop. Simply change this file location as per your own requirements and again try it yourself. Finally if you've any doubts, feel free to ask me in below comment box. I am always here to help you. Which method you've used? Stay connected for more interesting tutorials.

Leave A Comment