Subscribe to Windows IT Pro
February 07, 2012 12:00 AM

Q. How can I write a long command, over multiple lines, in either the command prompt window or a batch file?

Windows IT Pro
InstantDoc ID #142042
Rating: (0)

A. The Windows command prompt (cmd.exe) allows the ^ (Shift + 6) character to be used to indicate line continuation. It can be used both from the normal command prompt (which will actually prompt the user for more input if used) and within a batch file.

Below is an example of the character used in a command prompt (although it could easily have fit on one line):

D:\Temp>copy ^
        

More?a.a ^

More?b.b

1 file(s) copied.

I could place the same content in a batch file, and interestingly, when it’s run, it automatically puts the multiple lines onto a single line. For example, if my batch file contains the following:

copy ^
a.a ^
b.b

when I run it, I see the following on screen, which shows the command on one line:

<>D:\Temp>@badcopy.bat
        

D:\Temp>copy a.a b.b

1 file(s) copied.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.