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

Writing multiple line scripts? This line continuation character can help.

John Savill

February 6, 2012

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like