Split long commands in multiple lines through Windows batch file

Dan picture Dan · Sep 16, 2008 · Viewed 438.1k times · Source

How can I split long commands over multiple lines in a batch file?

Answer

Wayne picture Wayne · Sep 16, 2008

You can break up long lines with the caret ^ as long as you remember that the caret and the newline following it are completely removed. So, if there should be a space where you're breaking the line, include a space. (More on that below.)

Example:

copy file1.txt file2.txt

would be written as:

copy file1.txt^
 file2.txt