Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to copy multiple lines from the Windows Command Prompt without it inserting a new line where each line reaches the end of the terminal?

For example, if I have the following line in the console:

c:\very_long_path_here\more_path_here>command_i_want_to_copy -with -some
arguments that wrap over lines.

If I select this and copy it, I will get a newline after the word 'some', which I'll have to delete manually.

Is there a way to copy the data (command that will be parsed, output that is printed) in the form it is interpreted/printed, rather than with hard-wrapped lines?

share|improve this question
In Win 7/8 there is a clip.exe, which redirects input to clipboard. You can use it like c:\> echo your -command | clip.exe. But it's more suitable for a command output.. – week Mar 15 '13 at 10:37
afaik there is no built in way to do this. but maybe you can combine something like a short autoit script with clip.exe to archive your goal – weberik Mar 15 '13 at 12:41

2 Answers 2

The Windows Command Prompt is notoriously broken in this aspect. It is not possible to get the Linux Terminal behavior.

However, there is an obscure feature in cmd.exe which helps: Holding down shift when right clicking into the selected area (to copy) will remove ALL newlines in the copied text.

If you want to select a single long command line (spanning multiple terminal lines) this does what you want. However, it will always remove all newlines, so it is not possible to select multiple command lines (or a script) in a sensible way.

Detailled procedure:

  • Select long command line using the left mouse button
  • Press down shift
  • Right click into the selected area (to copy)
  • Release shift
  • Now the selected text is in the copy buffer without newlines and you can for example paste it into cmd.exe again using the right mouse button
share|improve this answer
Interesting, I'd never heard of that feature. It looks like that's as good as it's going to get. I don't use windows anymore, but when I get the chance to confirm it I'll accept this answer. :-) – Adam Millerchip Oct 9 at 2:32

Use the SET and then combine the parts in the expression. Additionally you can do for such purposes batch file or macro.

@set WAIKTools=%ProgramFiles%\WAIK\Tools\amd64

@IF "%time:~0,1%" GTR "0" SET current=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%@%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%
@IF "%time:~0,1%" LSS "0" SET current=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%@0%TIME:~1,1%.%TIME:~3,2%.%TIME:~6,2%

"%WAIKTools%\oscdimg.exe" -h -m -n -l%LabelCD% -b"%cd%\boot\w32sp3.bif" "BUILD-%current%" "BUILD-%current%-ISO\%LabelCD%.ISO"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.