views:

11670

answers:

1

How do I make long commands go over multiple lines in a Vista/DOS batch file?

+27  A: 

I believe you can break up long lines with the caret ^ as long as the next line starts with a space.

copy file1.txt file2.txt

would be written as:

copy file1.txt ^
 file2.txt
Wayne
You can start the next line without a space if you add a space just before the `^` and after your command text.
Joseph Daigle
Note: that a caret ^ after copy and file1.txt on a new line won't work.
Gavin Miller
**Thanks Joseph**. I fiddled with this a little before and could not use more than one added line. With a space before the caret, it works.
Jay
**@LFSR Consulting:** I just tried **"copy test ^[enter]test_2"** and it did work, at least for XP.
Jay
Seems to be limited to just the first two additional lines?
Seba Illingworth